Closed devaoto closed 6 months ago
Nevermind, fixed.
How did you fix the issue? I'm getting the same error
@SeoulSKY It happens when you authenticate with guest. You have to authenticate with your session token first then you can interact with your ai. You can modify this code as you like:
const CharacterAI = require('node_characterai');
const readline = require('readline');
const characterAI = new CharacterAI();
require('dotenv').config();
function getUserInput(question) {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
return new Promise((resolve) => {
rl.question(question, (answer) => {
rl.close();
resolve(answer);
});
});
}
(async () => {
await characterAI.authenticateWithToken(process.env.SESSION_TOKEN);
const characterId = process.env.CHARACTER_ID;
const chat = await characterAI.createOrContinueChat(characterId);
while (true) {
const userInput = await getUserInput('You: ');
const response = await chat.sendAndAwaitResponse(userInput, true);
console.log('AI:', response.text);
}
})();
Thank you so much! As you suggested, I tried using my own token instead of the guest token, and the example in README.md now works.
Hello, please see #155.
When I first example code shown on the readme, it returns this error:
I also tried using authentication, it throws the same error