canxin121 / async-poe-client Goto Github PK
View Code? Open in Web Editor NEWAsync Client for poe.com
Async Client for poe.com
2023-08-20 13:58:18.948 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 5/5)
2023-08-20 13:58:19.760 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 4/5)
2023-08-20 13:58:20.483 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 3/5)
2023-08-20 13:58:21.270 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 2/5)
2023-08-20 13:58:22.605 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 1/5)
2023-08-20 13:58:23.502 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 5/5)
2023-08-20 13:58:24.678 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 4/5)
2023-08-20 13:58:25.976 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 3/5)
2023-08-20 13:58:26.703 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 2/5)
2023-08-20 13:58:27.525 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 1/5)
2023-08-20 13:58:27.959 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 5/5)
2023-08-20 13:58:28.397 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 4/5)
2023-08-20 13:58:28.834 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 3/5)
2023-08-20 13:58:29.256 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 2/5)
2023-08-20 13:58:29.741 | ERROR | async_poe_client.client:send_query:291 - Failed to sending query:chatHelpersSendNewChatMessageMutation,error:Server Error. (retry: 1/5)
ERROR: Exception in ASGI application
2023-09-18 10:16:32.492 | INFO | async_poe_client.client:create:81 - Creating client -----
Traceback (most recent call last):
File "site-packages\aiohttp\connector.py", line 980, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Lib\asyncio\base_events.py", line 1112, in create_connection
transport, protocol = await self._create_connection_transport(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Lib\asyncio\base_events.py", line 1145, in _create_connection_transport
await waiter
File "Lib\asyncio\sslproto.py", line 575, in _on_handshake_complete
raise handshake_exc
File "Lib\asyncio\sslproto.py", line 557, in _do_handshake
self._sslobj.do_handshake()
File "Lib\ssl.py", line 979, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "site-packages\async_poe_client\client.py", line 93, in get_basedata
response = await client.get(HOME_URL, timeout=8)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "site-packages\aiohttp\client.py", line 536, in _request
conn = await self._connector.connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "site-packages\aiohttp\connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "site-packages\aiohttp\connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "site-packages\aiohttp\connector.py", line 1209, in _create_direct_connection
raise last_exc
File "site-packages\aiohttp\connector.py", line 1178, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "site-packages\aiohttp\connector.py", line 982, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host poe.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1006)')]
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "site-packages\async_poe_client\util.py", line 54, in wrapper
return await func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\anaconda\envs\poe11\Lib\site-packages\async_poe_client\client.py", line 96, in get_basedata
raise Exception("Failed to get basedata from home.") from e
Exception: Failed to get basedata from home.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Lib\runpy.py", line 88, in run_code
exec(code, run_globals)
File ".vscode\extensions\ms-python.python-2023.16.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy_main.py", line 39, in
cli.main()
File ".vscode\extensions\ms-python.python-2023.16.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File ".vscode\extensions\ms-python.python-2023.16.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File ".vscode\extensions\ms-python.python-2023.16.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".vscode\extensions\ms-python.python-2023.16.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File ".vscode\extensions\ms-python.python-2023.16.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "PoeAPI3.py", line 32, in
asyncio.run(process())
File "\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "\PoeAPI3.py", line 11, in process
poe_client = await Poe_Client("aJP5tjj%3D%3D", "c31e27aa33a0c").create()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "site-packages\async_poe_client\client.py", line 82, in create
await self.get_basedata()
File "site-packages\async_poe_client\util.py", line 57, in wrapper
raise Exception(f"{error_message}: {error}") from error
Exception: Failed to get base data: Failed to get basedata from home.
每个p-b都会对应一个formkey吗,还是只要有一个formkey,任何p-b都可以使用呢
token已填写,但是formkey不知道是什么
使用test.py文件函数直接运行,报错获取不到chat_code:Cell In[8], line 6
4 text+=message
5 await asyncio.sleep(3)
----> 6 chat_code = poe_client.bot_code_dict[name][0]
7 async for message in poe_client.ask_stream(url_botname='ChatGPT', question="写1句诗词", chat_code=chat_code,suggest_able= False):
8 print(message, end="")
File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\async_poe_client\client.py:64, in Poe_Client.bot_code_dict(self)
62 @Property
63 def bot_code_dict(self):
---> 64 return {
65 bot: [chat for chat in data["chats"]] for bot, data in self.bots.items()
66 }
File c:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\async_poe_client\client.py:65, in (.0)
62 @Property
63 def bot_code_dict(self):
64 return {
---> 65 bot: [chat for chat in data["chats"]] for bot, data in self.bots.items()
66 }
KeyError: 'chats'
When I create a poe_client , I got a error message:
Failed to sending query:availableBotsSelectorModalPaginationQuery,error:'errors'. (retry: 5/5)
Then I find the poe.com return message:
{"success":false,"message":"Bad Request"}
Can you add automatic retrieval of the formkey? There is such a function in poe-api
suggest_able and self.bots[url_botname]["bot"]["hasSuggestedReplies"]
KeyError: 'hasSuggestedReplies'
建议做成web api,例如openai的v1/completions
当我创建poe_client = await Poe_Client(token).create()时,会直接报错:
Failed to extract 'viewer' or 'user_id' from 'next_data'.
gpt_wz.py:None (gpt_wz.py)
gpt_wz.py:1: in
from async_poe_client import Poe_Client
/usr/local/lib/python3.9/site-packages/async_poe_client/init.py:1: in
from .client import Poe_Client
/usr/local/lib/python3.9/site-packages/async_poe_client/client.py:28: in
class Poe_Client:
/usr/local/lib/python3.9/site-packages/async_poe_client/client.py:280: in Poe_Client
async def send_query(self, query_name: str, variables: dict) -> Any | None:
E TypeError: unsupported operand type(s) for |: '_SpecialForm' and 'NoneType'
环境为:Mac+Python 3.9
在本机调试得时候没有问题,转移到服务器(境外)上调用create得时候就出现这个错误。版本0.2.
Traceback (most recent call last):
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/async_poe_client/client.py", line 96, in get_basedata
json_text = re.search(json_regex, text).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 419, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/fastapi/applications.py", line 289, in call
await super().call(scope, receive, send)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in call
raise e
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in call
await self.app(scope, receive, send)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/routing.py", line 69, in app
await response(scope, receive, send)
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/responses.py", line 270, in call
async with anyio.create_task_group() as task_group:
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 597, in aexit
raise exceptions[0]
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/responses.py", line 273, in wrap
await func()
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/starlette/responses.py", line 262, in stream_response
async for chunk in self.body_iterator:
File "/root/code/poe/poe.py", line 19, in sendmessage
poe_client = await Poe_Client(p_b, former_key).create()
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/async_poe_client/client.py", line 154, in create
raise e
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/async_poe_client/client.py", line 149, in create
await self.get_basedata()
File "/root/anaconda3/envs/ai/lib/python3.10/site-packages/async_poe_client/client.py", line 99, in get_basedata
raise ValueError("Failed to extract 'next_data' from the response.") from e
this is the bot objects that returned from poe
{'bot': {'__isNode': 'Bot',
'__typename': 'Bot',
'baseModelDisplayName': 'GPT-4',
'botId': 3007,
'deletionState': 'not_deleted',
'displayName': 'GPT-4',
'handle': 'GPT-4',
'id': 'Qm90OjMwMDc=',
'image': {'__typename': 'LocalBotImage',
'localName': 'Avatar_GPT_Blue'},
'isApiBot': False,
'isDown': False,
'isLimitedAccess': True,
'isPrivateBot': False,
'isSystemBot': True,
'limitedAccessType': 'soft_limit',
'messageLimit': {'dailyLimit': 1,
'id': 'TWVzc2FnZUxpbWl0Om1vZGVsOjMwMDc=',
'numMessagesRemaining': 594,
'shouldShowRemainingMessageCount': False,
'shouldShowSubscriptionRationale': False},
'nickname': 'beaver',
'uploadFileSizeLimit': 100000000,
'viewerIsCreator': False}}
and this is the error message : Exception: Failed to send msg to GPT-4: 'chats'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.