Closed zhouhh2017 closed 1 year ago
from async_poe_client import Poe_Client import asyncio
async def fetch_data():
await asyncio.sleep(2)
return "Data has been fetched"
async def process():
poe_client = await Poe_Client("aJP5tjjBg%3D%3D", "c31e27a97d5a33a0c").create()
await poe_client.create_bot(handle="testbotcx1", prompt="a ai assistant")
await poe_client.edit_bot(url_botname="test27gs", handle="test27gs2", prompt="a computer programmer",base_model="a2")
# The get_available_bots() function can be found in item 8 with usage instructions.
# If chat_code is not provided, a new chat window will be automatically created, and its chat_code can be obtained from the poe_client's property.
async for message in poe_client.ask_stream(url_botname='ChatGPT', question="introduce async and await"):
print(message, end="")
# The bot_code_dict attribute can be accessed to get a dictionary with url_botname as the key and List[chat_code] as the value. The order is from newest to oldest, and the first one is the chat_code that was just automatically created.
chat_code = poe_client.bot_code_dict['ChatGPT'][0]
# Continue the conversation using the chat_code obtained earlier
async for message in poe_client.ask_stream(url_botname='ChatGPT', chat_code=chat_code,
question="introduce async and await"):
print(message, end="")
# If suggested replies are used and you want a list of suggested replies, they can be extracted from the bots attribute, which records the last suggested reply of a bot in a specific chat.
print(poe_client.bots['ChatGPT']['chats'][chat_code]['Suggestion'])
asyncio.run(process())
I don't think your p-b and formkey are correct. Check them and try again.
I don't think your p-b and formkey are correct. Check them and try again. Should I send you my real p-b and formkey?
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 _createconnection , 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.