kramcat / CharacterAI

Unofficial Python API for character.ai
https://docs.kram.cat
MIT License
378 stars 51 forks source link

chat2.new_chat returns "characterai.errors.ServerError: create_chat already exists" #57

Closed Arutemu64 closed 8 months ago

Arutemu64 commented 9 months ago

Here I'm trying to reset the chat by using new_chat (I hope I'm doing it right...)

chat = (await cai_client.chat2.get_chat(CHAR))["chats"][0]
user = (await cai_client.user.info())["user"]["user"]
async with cai_client.connect() as chat2:
    await chat2.new_chat(
        char=env("CHAR"),
        chat_id=chat["chat_id"],
        creator_id=str(user["id"]),
)

And here's what I receive

File "~~~\Lib\site-packages\characterai\pyasynccai.py", line 718, in new_chat
    raise errors.ServerError(response['comment'])
characterai.errors.ServerError: create_chat already exists
Arutemu64 commented 8 months ago

Answering my question, chat_id can be anything, it's not explicitly server-generated, but it should not exist before. Timestamp is good enough as a chat_id.