snowby666 / poe-api-wrapper

👾 A Python API wrapper for Poe.com. With this, you will have free access to GPT-4, Claude, Llama, Gemini, Mistral and more! 🚀
https://pypi.org/project/poe-api-wrapper/
GNU General Public License v3.0
677 stars 81 forks source link

代理问题 proxy problem #151

Closed toyosky closed 1 week ago

toyosky commented 1 month ago

当我使用代理的时候,会一直显示连接丢失。这是为什么? 2024-05-11 16:25:03.639 | INFO | poe_api_wrapper.api:select_proxy:80 - Connection failed with {'https': '127.0.0.1:7890', 'http': '127.0.0.1:7890'}. Trying 1/1 ... 2024-05-11 16:25:03.801 | WARNING | poe_api_wrapper.api:on_ws_close:201 - Connection to remote host was lost. Reconnecting... 2024-05-11 16:25:27.572 | WARNING | poe_api_wrapper.api:on_ws_close:201 - Connection to remote host was lost. Reconnecting... 而当我使用[proxy]版本的时候,则提醒我访问次数过多。 raise RuntimeError("Rate limit exceeded for sending requests to poe.com. Please try again later.") RuntimeError: Rate limit exceeded for sending requests to poe.com. Please try again later. 所以我应该要如何使用代理呢?

deadmau5v commented 3 weeks ago

如果你要使用本地代理 例如 clash 安装这个版本 pip install -U poe-api-wrapper[proxy] 然后修改 poe_api_wrapper/proxies.py

import ballyregan

try:
    from ballyregan.models import Protocols

    PROXY = True
except:
    PROXY = False

if PROXY:
    def fetch_proxy():
        http = ballyregan.Proxy(
            ip="127.0.0.1",
            port="7890",
            protocol=Protocols.HTTP,
        )
        https = ballyregan.Proxy(
            ip="127.0.0.1",
            port="7890",
            protocol=Protocols.HTTPS,
        )
        return [http, https]

然后在你的py文件中 开启代理

PoeApi(..., proxy=True)
snowby666 commented 1 week ago

This should be fixed in the new version