kramcat/CharacterAI

Error when chatting with a new Character.

Closed this issue · 1 comments

Whenever I start a chat with a character that I have no previous history of chatting with, I encounter an Exception with the JSONDecodeError.
The Raise Exception is:

Exception has occurred: JSONDecodeError
Expecting value: line 2 column 1 (char 1)
StopIteration: 1

During handling of the above exception, another exception occurred:

  File "C:\Users\User\Test\app.py", line 9, in <module>
    chat = client.chat.get_chat(char)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

I read from a previous issue that this exception is only raised when the server of CharacterAI is either down or overloaded. But this doesn't seem to be the case in this error.

Karvp commented

Hi there,
Your error is caused by the server's response when you attempt to chat with a new character. Please look at the response below:
there is no history between user and character
Yes, it came with a 404 error and is not in JSON format; that's why there is an error. To fix this, you should try to maintain the library on your own to handle this error.

P/s: Try to play with character.ai's API to understand it better. You can use the Chrome devtools like I did.