kramcat / CharacterAI

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

characterai.errors.ServerError: Unauthorized #28

Closed aquadeve closed 11 months ago

aquadeve commented 1 year ago

Code:

from characterai import PyCAI

client = PyCAI('TOKEN')

while True: message = input('You: ')

data = client.chat.send_message('CHAR', message)

if data['replies']:
    reply = data['replies'][0]['text']
    name = data['src_char']['participant']['name']
    print(f"{name}: {reply}")
else:
    print("Error: No reply from the character.")

# Check if the conversation is finished
if 'conversation_finished' in data and data['conversation_finished']:
    print("Conversation ended.")
    break

You: hello fellow hows your day Traceback (most recent call last): File "C:\Users\Administrator\Downloads\Consoles\XboxOne\A.py", line 8, in data = client.chat.send_message('92i0UeYAM6hKG1ojgoprsR4MwStyZfrHS8qDufRWo3A', message) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\characterai\characterai.py", line 383, in send_message info = PostResponse( ^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\characterai\characterai.py", line 82, in PostResponse raise errors.ServerError(response.status_text) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ characterai.errors.ServerError: Unauthorized

KubaPro010 commented 1 year ago

You just don't have access to that character, it's not a wrapper error

SylesGH commented 11 months ago

You just don't have access to that character, it's not a wrapper error

Why it doesn't have access. Is there a way to fix that? I'm having this problem too but I especially need that character.

KubaPro010 commented 11 months ago

It just doesn't, they don't give you full access to the database either, there's no explaining to be done, you can try to create your own character that has the same attributes (like name, description, greeting, etc.)

kramcat commented 11 months ago

in client = PyCAI('TOKEN') you should set TOKEN value