kramcat / CharacterAI

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

Expecting value: line 1 column 1 (char 0) #77

Closed SSL-ACTX closed 6 months ago

SSL-ACTX commented 6 months ago

Hello, I kept having this problem when I switch to certain characters, Hu Tao, Character Assitant, and Stella works fine, but Raiden and other characters doesn't work at all and gives this error:

image

Here's my code:

from characterai import PyCAI

client = PyCAI('my-token')

char = "RQrrOj-UNdEV2_PC5D03US-27MZ7EUtaRH_husjbRQA"

chat = client.chat.get_chat(char)

participants = chat['participants']

if not participants[0]['is_human']:
    tgt = participants[0]['user']['username']
else:
    tgt = participants[1]['user']['username']

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

    data = client.chat.send_message(
        chat['external_id'], tgt, message
    )

    name = data['src_char']['participant']['name']
    text = data['replies'][0]['text']

    print(f"{name}: {text}")
Karvp commented 6 months ago

As I suggested in this issue, the server's response to the API request may not be in the form of JSON, and that caused the exception. There might be several reasons for this (e.g., not found, unauthorized, invisible character, etc.). I encourage you to debug the library code to find out the error.

SSL-ACTX commented 6 months ago

I see. Thanks for the response.