xtekky / gpt4free

The official gpt4free repository | various collection of powerful language models
https://g4f.ai
GNU General Public License v3.0
59.42k stars 13.2k forks source link

[OpenaiChat] Error 403 when making the second request to the gui API #1732

Closed iG8R closed 3 months ago

iG8R commented 4 months ago
(venv) c:\gpt4free>g4f api --debug DEBUG --ignored-providers AItianhu AItianhuSpace Acytoo AiAsk AiChatOnline AiChatting AiService Aibn Aichat Ails Aivvm AsyncGeneratorProvider AsyncProvider Aura Bard BaseProvider Berlin Bestim Bing ChatAiGpt ChatAnywhere ChatBase ChatForAi Chatgpt4Online ChatgptAi ChatgptDemo ChatgptDemoAi ChatgptDuo ChatgptFree ChatgptLogin ChatgptNext ChatgptX Chatxyz CodeLinkAva CreateImagesProvider Cromicle DeepInfra DfeHub EasyChat Equing FakeGpt FastGpt Forefront FreeChatgpt FreeGpt GPTalk GeekGpt Gemini GeminiProCCFgptCN GeminiProChat GeminiProFreeChatGPT GeminiProGBeCo GeminiProTop GetGpt Gpt6 GptChatly GptForLove GptGo GptGod GptTalkRu H2o Hashnode HuggingChat Koala Komo Liaobots Llama2 Lockchat MikuChat MyShell Myshell OnlineGpt Opchatgpts OpenAssistant PerplexityAi PerplexityLabs Phind Pi Poe Raycast RetryProvider TalkAi Theb ThebApi V50 Vercel Vitalentum Wewordle Wuguokai Ylokh You Yqcloud
INFO:     Started server process [20612]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:1337 (Press CTRL+C to quit)
Using OpenaiChat provider and gpt-3.5-turbo model                         <--- first request
Read cookies from chrome for chat.openai.com
Read cookies from edge for chat.openai.com
Read cookies from firefox for chat.openai.com
Open browser with config dir: C:\Users\iG8R\AppData\Local\g4f\g4f
INFO:     127.0.0.1:52181 - "POST /v1/chat/completions?provider=OpenaiChat HTTP/1.1" 200 OK
Using OpenaiChat provider and gpt-3.5-turbo model                         <--- second request
ERROR:root:Response 403: <html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style global>
      body {
        font-family: Arial, Helvetica, sans-serif;
      }
      .container {
        display: flex;
        width: 100%;
        height: 100%;
        justify-content: center;
        align-items: center;
        flex-direction: column;
      }
      @keyframes enlarge-appear {
        from {
          opacity: 0;
          transform: scale(75%) rotate(-90deg);
        }

        to {
          opacity: 1;
          transform: scale(100%) rotate(0deg);
        }
      }

      .logo {
        color: #8e8ea0;
        padding-bottom: 1.5rem;
      }

      .scale-appear {
        animation: enlarge-appear 400ms ease-out;
      }

      @media (min-width: 768px) {
        .scale-appear {
          width: 48px;
          height: 48px;
        }
      }

      .data:empty {
        display: none;
      }

      .data {
        border-radius: 5px;
        color: #8e8ea0;
        text-align: center;
        width: 100%;
        max-width: 420px;
      }

      .data ul {
        list-style: none;
        padding: 0;
      }

      .blocked-icon {
        color: #ef4444;
      }

      .message {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        font-size: 1.5rem;
      }

      .explanation {
        font-size: 0.9rem;
        opacity: 50%;
        width: 100%;
        max-width: 420px;
        text-align: center;
        line-height: 1.5;
      }

      .explanation a {
        color: black;
      }

      @media (prefers-color-scheme: dark) {
        body {
          background-color: #343541;
          color: #eee;
        }

        .logo {
          color: #acacbe;
        }

        .explanation a {
          color: white;
        }
      }
    </style>

</head>
  <body>
    <div class="container">
      <div class="logo">
        <svg
          width="41"
          height="41"
          viewBox="0 0 41 41"
          fill="none"
          xmlns="http://www.w3.org/2000/svg"
          strokeWidth="2"
          class="scale-appear"
        >
          <path
            d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.0068 29.9541 21.0198 29.9656 21.0359C29.977 21.052 29.9842 21.0707 29.9867 21.0902V30.3889C29.9842 32.375 29.1946 34.2791 27.7933 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z"
            fill="currentColor"
          />
        </svg>
      </div>
      <div class="message">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          fill="none"
          width="24"
          height="24"
          viewBox="0 0 24 24"
          stroke-width="1.5"
          stroke="currentColor"
          class="blocked-icon"
        >
          <path
            stroke-linecap="round"
            stroke-linejoin="round"
            d="M12 9v3.75m0-10.036A11.95-8.25-3.286zm0 13.036h.008v.008H12v-.008z"
          />
        </svg>
        <p>Unable to load site</p>
      </div>
      <span class="explanation">
        Please try again later. If you are using a VPN, try turning it off.
        Check the
        <a href="https://status.openai.com/" target="_new">status page</a> for
        information on outages.
      </span>
      <br />
      <span class="explanation"> [IP:xxx.xxx.xxx.xxx | Ray ID:xxxxxxxxxxxx] </span>
    </div>
  <script>(function(){if (!document.body) return;var js = "window['__CF$cv$params']={r:'TcxMDkzMTEwNy4xNjMwMDA='};_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js',document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script></body>
</html>
Traceback (most recent call last):
  File "c:\gpt4free\venv\Lib\site-packages\g4f\api\__init__.py", line 91, in chat_completions
    response = self.client.chat.completions.create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\gpt4free\venv\Lib\site-packages\g4f\client.py", line 163, in create
    return response if stream else next(response)
                                   ^^^^^^^^^^^^^^
  File "c:\gpt4free\venv\Lib\site-packages\g4f\client.py", line 84, in iter_append_model_and_provider
    for chunk in response:
  File "c:\gpt4free\venv\Lib\site-packages\g4f\client.py", line 49, in iter_response
    for idx, chunk in enumerate(response):
  File "c:\gpt4free\venv\Lib\site-packages\g4f\providers\base_provider.py", line 206, in create_completion
    yield loop.run_until_complete(await_callback(gen.__anext__))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\gpt4free\venv\Lib\site-packages\nest_asyncio.py", line 99, in run_until_complete
    return f.result()
           ^^^^^^^^^^
  File "C:\Python312\Lib\asyncio\futures.py", line 203, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "C:\Python312\Lib\asyncio\tasks.py", line 304, in __step_run_and_handle_result
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "c:\gpt4free\venv\Lib\site-packages\g4f\providers\base_provider.py", line 202, in await_callback
    return await callback()
           ^^^^^^^^^^^^^^^^
  File "c:\gpt4free\venv\Lib\site-packages\g4f\Provider\needs_auth\OpenaiChat.py", line 452, in create_async_generator
    await raise_for_status(response)
  File "c:\gpt4free\venv\Lib\site-packages\g4f\requests\raise_for_status.py", line 23, in raise_for_status_async
    raise ResponseStatusError(f"Response {response.status}: {message}")
g4f.errors.ResponseStatusError: Response 403: <html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style global>
      body {
        font-family: Arial, Helvetica, sans-serif;
      }
      .container {
        display: flex;
        width: 100%;
        height: 100%;
        justify-content: center;
        align-items: center;
        flex-direction: column;
      }
      @keyframes enlarge-appear {
        from {
          opacity: 0;
          transform: scale(75%) rotate(-90deg);
        }

        to {
          opacity: 1;
          transform: scale(100%) rotate(0deg);
        }
      }

      .logo {
        color: #8e8ea0;
        padding-bottom: 1.5rem;
      }

      .scale-appear {
        animation: enlarge-appear 400ms ease-out;
      }

      @media (min-width: 768px) {
        .scale-appear {
          width: 48px;
          height: 48px;
        }
      }

      .data:empty {
        display: none;
      }

      .data {
        border-radius: 5px;
        color: #8e8ea0;
        text-align: center;
        width: 100%;
        max-width: 420px;
      }

      .data ul {
        list-style: none;
        padding: 0;
      }

      .blocked-icon {
        color: #ef4444;
      }

      .message {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        font-size: 1.5rem;
      }

      .explanation {
        font-size: 0.9rem;
        opacity: 50%;
        width: 100%;
        max-width: 420px;
        text-align: center;
        line-height: 1.5;
      }

      .explanation a {
        color: black;
      }

      @media (prefers-color-scheme: dark) {
        body {
          background-color: #343541;
          color: #eee;
        }

        .logo {
          color: #acacbe;
        }

        .explanation a {
          color: white;
        }
      }
    </style>

</head>
  <body>
    <div class="container">
      <div class="logo">
        <svg
          width="41"
          height="41"
          viewBox="0 0 41 41"
          fill="none"
          xmlns="http://www.w3.org/2000/svg"
          strokeWidth="2"
          class="scale-appear"
        >
          <path
            d="M37.5324 16.8707C37.9808 15.5241 38.1363 14.0974 37.9886 12.6859C37.8409 11.2744 37.3934 9.91076 36.676 8.68622C35.6126 6.83404 33.9882 5.3676 32.0373 4.4985C30.0864 3.62941 27.9098 3.40259 25.8215 3.85078C24.8796 2.7893 23.7219 1.94125 22.4257 1.36341C21.1295 0.785575 19.7249 0.491269 18.3058 0.500197C16.1708 0.495044 14.0893 1.16803 12.3614 2.42214C10.6335 3.67624 9.34853 5.44666 8.6917 7.47815C7.30085 7.76286 5.98686 8.3414 4.8377 9.17505C3.68854 10.0087 2.73073 11.0782 2.02839 12.312C0.956464 14.1591 0.498905 16.2988 0.721698 18.4228C0.944492 20.5467 1.83612 22.5449 3.268 24.1293C2.81966 25.4759 2.66413 26.9026 2.81182 28.3141C2.95951 29.7256 3.40701 31.0892 4.12437 32.3138C5.18791 34.1659 6.8123 35.6322 8.76321 36.5013C10.7141 37.3704 12.8907 37.5973 14.9789 37.1492C15.9208 38.2107 17.0786 39.0587 18.3747 39.6366C19.6709 40.2144 21.0755 40.5087 22.4946 40.4998C24.6307 40.5054 26.7133 39.8321 28.4418 38.5772C30.1704 37.3223 31.4556 35.5506 32.1119 33.5179C33.5027 33.2332 34.8167 32.6547 35.9659 31.821C37.115 30.9874 38.0728 29.9178 38.7752 28.684C39.8458 26.8371 40.3023 24.6979 40.0789 22.5748C39.8556 20.4517 38.9639 18.4544 37.5324 16.8707ZM22.4978 37.8849C20.7443 37.8874 19.0459 37.2733 17.6994 36.1501C17.7601 36.117 17.8666 36.0586 17.936 36.0161L25.9004 31.4156C26.1003 31.3019 26.2663 31.137 26.3813 30.9378C26.4964 30.7386 26.5563 30.5124 26.5549 30.2825V19.0542L29.9213 20.998C29.9389 21.006.6878 36.8382 27.0432 35.9743 28.1759C35.1103 29.3086 33.9415 30.1717 32.6047 30.6641C32.6047 30.5947 32.6047 30.4733 32.6047 30.3889V21.188C32.6066 20.9586 32.5474 20.7328 32.4332 20.5338C32.319 20.3348 32.154 20.1698 31.955 20.0556ZM35.3055 15.0128C35.2464 14.9765 35.1431 14.9142 35.069 14.8717L27.1045 10.2712C26.906 10.1554 26.6803 10.0943 26.4504 10.0943C26.2206 10.0943 25.9948 10.1554 25.7963 10.2712L16.0726 15.8858V11.9982C16.0715 11.9783 16.0753 11.9585 16.0837 11.9405C16.0921 11.9225 16.1048 11.9068 16.1207 11.8949L24.1719 7.25025C25.4053 6.53903 26.8158 6.19376 28.2383 6.25482C29.6608 6.31589 31.0364 6.78077 32.2044 7.59508C33.3723 8.40939 34.2842 9.53945 34.8334 10.8531C35.3826 12.1667 35.5464 13.6095 35.3055 15.0128ZM14.2424 21.9419L10.8752 19.9981C10.8576 19.9893 10.8423 19.9763 10.8309 19.9602C10.8195 19.9441 10.8122 19.9254 10.8098 19.9058V10.6071C10.8107 9.18295 11.2173 7.78848 11.9819 6.58696C12.7466 5.38544 13.8377 4.42659 15.1275 3.82264C16.4173 3.21869 17.8524 2.99464 19.2649 3.1767C20.6775 3.35876 22.0089 3.93941 23.1034 4.85067C23.0427 4.88379 22.937 4.94215 22.8668 4.98473L14.9024 9.58517C14.7025 9.69878 14.5366 9.86356 14.4215 10.0626C14.3065 10.2616 14.2466 10.4877 14.2479 10.7175L14.2424 21.9419ZM16.071 17.9991L20.4018 15.4978L24.7325 17.9975V22.9985L20.4018 25.4983L16.071 22.9985V17.9991Z"
            fill="currentColor"
          />
        </svg>
      </div>
      <div class="message">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          fill="none"
          width="24"
          height="24"
          viewBox="0 0 24 24"
          stroke-width="1.5"
          stroke="currentColor"
          class="blocked-icon"
        >
          <path
            stroke-linecap="round"
            stroke-linejoin="round"
            d="M12 9v3.75m0- 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.57-.598-3.75h-.152c-3.196 0-6.1-1.249-8.25-3.286zm0 13.036h.008v.008H12v-.008z"
          />
        </svg>
        <p>Unable to load site</p>
      </div>
      <span class="explanation">
        Please try again later. If you are using a VPN, try turning it off.
        Check the
        <a href="https://status.openai.com/" target="_new">status page</a> for
        information on outages.
      </span>
      <br />
      <span class="explanation"> [IP:xxx.xxx.xxx.xxx | Ray ID:xxxxxxxxxxxxxx] </span>
    </div>
  <script>(function(){if (!document.body) return;var js = "window['__CF$cv$params']={r:'MTcxMDkzMTEwNy4xNjMwMDA='};_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js',document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script></body>
</html>

INFO:     127.0.0.1:52181 - "POST /v1/chat/completions?provider=OpenaiChat HTTP/1.1" 500 Internal Server Error
iG8R commented 4 months ago

PS. OpenaiChat from version 0.2.4.1 works fine.

haroooooo12345666666 commented 4 months ago

PS. OpenaiChat from version 0.2.4.1 works fine.

I have the same problem but this version does not work either.

github-actions[bot] commented 4 months ago

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

Gradess2019 commented 3 months ago

Tried OpenaiChat provider today and encountered same error. Any solution?

iG8R commented 3 months ago

Tried OpenaiChat provider today and encountered same error. Any solution?

Update to the new version, e.g. 0.2.7.2.