poe-api-wrapper icon indicating copy to clipboard operation
poe-api-wrapper copied to clipboard

With proxy, websocket error

Open wupan-olo opened this issue 1 year ago • 0 comments

env:

  • macos m2
  • python 3.9+
  • poe-api-wrapper 1.4.1
# model
gpt_4_128 = 'vizcacha'
gpt_4 = 'beaver'
gpt_35 = 'gpt3_5'

# proxy 
proxy_config = [
    {"https":"socks5://127.0.0.1:7890",
     "http":"socks5://127.0.0.1:7890"}
]

msg = 'Hi, introduce yourself'

client = poe.PoeApi(cookie=poe_token, proxy=proxy_config)
 # no-stream read:
for chunk in client.send_message(bot= gpt_35, message = msg):
   pass
print(chunk["text"])

It work well for print(client.get_chat_history()['data'])

err log:

/Users/wupan/anaconda3/envs/prompt/lib/python3.9/site-packages/websocket/_app.py:356: ResourceWarning: unclosed <socket.socket fd=79, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('172.31.8.156', 60556)> return not isinstance(e, KeyboardInterrupt) ResourceWarning: Enable tracemalloc to get the object allocation traceback 2024-04-16 10:29:12.936 | INFO | poe_api_wrapper.api:select_proxy:80 - Connection failed with {'https': 'socks5://127.0.0.1:7890', 'http': 'socks5://127.0.0.1:7890'}. Trying 1/1 ... 2024-04-16 10:29:13.835 | WARNING | poe_api_wrapper.api:on_ws_close:201 - Connection to remote host was lost. Reconnecting... 2024-04-16 10:29:20.631 | WARNING | poe_api_wrapper.api:on_ws_close:201 - Connection to remote host was lost. Reconnecting...

wupan-olo avatar Apr 16 '24 02:04 wupan-olo