kramcat / CharacterAI

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

NameError: name 'page' is not defined #34

Closed sushipro-314 closed 1 year ago

sushipro-314 commented 1 year ago

File MYDIRECTORY/venv\lib\site-packages\characterai\pyasynccai.py", line 16, in goto await page.goto(f'https://beta.character.ai/{link}') NameError: name 'page' is not defined

This is the error when I try sending a message to the api with my code below: (not all of the code is shown below because of the other project i'm working on, a discord bot)

from characterai import PyAsyncCAI

caiToken = "CENSORED"

cclient = PyAsyncCAI(caiToken) print(f"{char}: {msg}") data = await cclient.chat.send_message(char, msg)

sushipro-314 commented 1 year ago

Oh btw I did await inside a function

KubaPro010 commented 1 year ago

Didn't you read the docs? You have to use the .start() function, here:

from characterai import PyAsyncCAI

caiToken = "YOUR_TOKEN"

cclient = PyAsyncCAI(caiToken)
cclient.start()
print(f"{char}: {msg}")
data = await cclient.chat.send_message(char, msg)
sushipro-314 commented 1 year ago

ok thank you! sorry i'm somewhat knew to python so i was confused. i'll try it tomorrow when i'm at my computer.

sushipro-314 commented 1 year ago

Ok i tested it, it still says the same error, whether I add the cclient.start() or not.

KubaPro010 commented 1 year ago

That shouldn't happen, try adding page = None at the top of the PyAsyncCAI file

sushipro-314 commented 1 year ago

It gives me a different error when I add the code page = None to the file.

AttributeError: 'NoneType' object has no attribute 'goto'

KubaPro010 commented 1 year ago

Try re-installing the library, use pip uninstall characterai and then pip install characterai