kramcat / CharacterAI

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

Validation Error #107

Open hk92292831 opened 4 months ago

hk92292831 commented 4 months ago

Anyone know how to fix the following error?

image

GearStarter commented 4 months ago

Recently, this code stopped working. Perhaps some kind of update from C.AI . I get the same error. devenv_Aw4v8Frkep

GearStarter commented 4 months ago

kramcat replied to me pip install pydantic==2.7.0

But I got a new error.

2 validation errors for NewChat
participants.0.user.account.mobile_onboarding_complete
  Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/int_type
speech
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type
GearStarter commented 4 months ago

It looks like there have been changes in the API. Many functions do not work, both in sync and in async.

By some miracle, I managed to run the old code on async. I hope the author will fix everything soon.

from characterai import aiocai
import asyncio

my_token = "my_token"
my_character = "my_character"

async def chating():
    chat_data = await client.get_chat(my_character)
    async with await client.connect() as chat:
        while True:
            message_user = input("You: ")
            ai_message = await chat.send_message(my_character, chat_data.chat_id, message_user)
            print("AI: " + ai_message.text)

client = aiocai.Client(my_token)
asyncio.run(chating())