CharacterAI icon indicating copy to clipboard operation
CharacterAI copied to clipboard

TypeError: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers'

Open xhrt opened this issue 1 year ago • 8 comments

When run the examples:

from characterai import aiocai import asyncio

async def main(): char = "" client = aiocai.Client("") me = await client.get_me()

async with await client.connect() as chat:
    new, answer = await chat.new_chat(
        char, me.id
    )

    print(f'{answer.name}: {answer.text}')

    while True:
        text = input('YOU: ')

        message = await chat.send_message(
            char, new.chat_id, text
        )

        print(f'{message.name}: {message.text}')

asyncio.run(main()) I meet the following error: Traceback (most recent call last): File "/home/ubuntu/CBT3.0/character.ai/character_ai.py", line 49, in asyncio.run(main()) File "/home/ubuntu/anaconda3/envs/characterai/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/home/ubuntu/anaconda3/envs/characterai/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/home/ubuntu/CBT3.0/character.ai/character_ai.py", line 32, in main async with await client.connect() as chat: File "/home/ubuntu/anaconda3/envs/characterai/lib/python3.10/site-packages/characterai/aiocai/methods/chat2.py", line 440, in call return await self.aenter(self.token) File "/home/ubuntu/anaconda3/envs/characterai/lib/python3.10/site-packages/characterai/aiocai/methods/chat2.py", line 447, in aenter self.ws = await websockets.connect( File "/home/ubuntu/anaconda3/envs/characterai/lib/python3.10/site-packages/websockets/asyncio/client.py", line 441, in await_impl self.connection = await self.create_connection() File "/home/ubuntu/anaconda3/envs/characterai/lib/python3.10/site-packages/websockets/asyncio/client.py", line 367, in create_connection _, connection = await loop.create_connection(factory, **kwargs) TypeError: BaseEventLoop.create_connection() got an unexpected keyword argument 'extra_headers' I can't figure it out.Could you please help me with it? My packages are as follows: characterai:1.0.1 pydantic:2.7.1 websockets:14.0

xhrt avatar Nov 12 '24 09:11 xhrt

Have the same problem. 😕

dmytro-varich avatar Nov 22 '24 15:11 dmytro-varich

installing websockets==11.0.3 solved this issue.

1000MilesAway avatar Nov 23 '24 16:11 1000MilesAway

how to fix?

khunchaiyakorn avatar Nov 30 '24 11:11 khunchaiyakorn

how to fix?

installing websockets==11.0.3 solved this issue.

dmytro-varich avatar Nov 30 '24 15:11 dmytro-varich

how to fix?

installing websockets==11.0.3 solved this issue.

thank you it wworks

Zectxr avatar Dec 07 '24 22:12 Zectxr

Hey, i have installed websockets 11.0.3 but still have the issue, any idea ?

catttuhh avatar Feb 26 '25 20:02 catttuhh

Hey, i have installed websockets 11.0.3 but still have the issue, any idea ?

My recommendation is using a venv so you don't encounter package incompability issues, the websockets to 11.0.3 solves the issue mainly.

Alyxhelpme avatar Mar 27 '25 05:03 Alyxhelpme

why is this?use websockets 11.0.3 can :(

mumangguo avatar May 01 '25 17:05 mumangguo