kramcat / CharacterAI

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

Didnt work #45

Closed CUSTOMFAIL closed 10 months ago

CUSTOMFAIL commented 10 months ago


client = PyCAI("XXXXXXXXXXXXXXXXXXXXXXX")
client.start()

char = 'XXXXXXXXXXXXXXXXXXXXX'

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}")```

```Traceback (most recent call last):
  File "<module1>", line 37, in <module>
  File "C:\Users\luvut\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\luvut\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "<module1>", line 13, in main
  File "C:\Users\luvut\AppData\Local\Programs\Python\Python310\lib\site-packages\characterai\pyasynccai.py", line 567, in get_chat
    return await _PostResponse(
  File "C:\Users\luvut\AppData\Local\Programs\Python\Python310\lib\site-packages\characterai\pyasynccai.py", line 79, in _PostResponse
    raise errors.ServerError(response.status_text)
characterai.errors.ServerError: Not Found```
kramcat commented 10 months ago

Maybe you don't have a chat with the character, check chat.new_chat() in documentation

CUSTOMFAIL commented 10 months ago

Maybe you don't have a chat with the character, check chat.new_chat() in documentation

thanks it worked