CharacterAI
CharacterAI copied to clipboard
TLSClientException
Hello,
I am currently trying to run the example code with my own token and character id, however there seems to be a little problem:
from characterai import PyCAI
client = PyCAI('My Token')
char = input('Enter CHAR: ')
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}")
and Python says:
Traceback (most recent call last):
File "C:\Users\Admin\test.py", line 7, in <module>
chat = client.chat.get_chat(char)
File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\characterai\characterai.py", line 531, in get_chat
return PyCAI.request(
File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\characterai\characterai.py", line 57, in request
response = session.post(
File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\tls_client\sessions.py", line 448, in post
return self.execute_request(method="POST", url=url, data=data, json=json, **kwargs)
File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\tls_client\sessions.py", line 405, in execute_request
raise TLSClientExeption(response_object["body"])
tls_client.exceptions.TLSClientExeption: failed to do request: Post "https://beta.character.ai/chat/history/continue/": dial tcp 104.244.46.71:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
So is it my problem or the problem of the API - and how am I able to fix it? Appreciated if answered🥰
Hi there! It seems like there's a connectivity issue when trying to establish a connection with the Character AI server. Here are a few things to check:
- Network Connection: Ensure your internet connection is stable.
- Firewall/Antivirus: Check for any software that might be blocking the connection.
- Server Status: Verify if the Character AI server is operational. 😅
- API Token: Confirm that the token you're using is correct and valid.
Hope this helps!
I also encountered this problem.
check on new version