CharacterAI
CharacterAI copied to clipboard
Validation problems with Character class
Calling get_char() results in a ValidationError because of None values in some fields.
import asyncio
from characterai import aiocai
def get_client():
token = config.get("AI", "cai_api", fallback=None)
if not token:
delete_cai_chats()
raise ValueError("CAI API token is missing in config file.")
return aiocai.Client(token=token)
async def get_char_info(character_id):
async with get_client() as account:
return await account.get_char(character_id)
print(asyncio.run(get_char_info(char_id)))
Gets me this:
pydantic_core._pydantic_core.ValidationError: 1 validation error for Character
songs
Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.11/v/list_type
And sometimes this:
songs
Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.11/v/list_type
comments_enabled
Input should be a valid boolean [type=bool_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.11/v/bool_type