Comments (30)
Could you show me the code? Have you sure you put the correct token? I have tried it on my environment and it works perfectly.
from node_characterai.
Here's the code which, aside from the Discord stuff and the character, I basically copied from the example. It might be a bit messy as I'm still kinda a noob with js.
Do you have the testing environment or some basic code which I could use to test if it works? Looking at an older issue #1 has the same error I get, but it wasn't very clear to me what they did to fix it.
const { SlashCommandBuilder } = require('discord.js');
const node_characterai = require('node_characterai');
const characterAI = new node_characterai();
module.exports = {
data: new SlashCommandBuilder()
.setName('cai')
.setDescription("Talk to Braixen from Character.AI! Remember, don't take anything an AI says seriously.")
.addStringOption(option =>
option
.setName('message')
.setDescription('What is your message to them?')
.setRequired(true)
),
async execute(interaction, responseMessage, dateTime) {
const message = interaction.options.getString('message')
await characterAI.authenticateAsGuest();
const characterId = "FdOuMH3rMG39zYwTvu5qIYcHda9_oMMpU14BolueOcI";
const chat = await characterAI.createOrContinueChat(characterId);
const response = await chat.sendAndAwaitResponse(message, true);
responseMessage = "";
await interaction.reply(responseMessage);
console.log(`${dateTime} Responded to commands with ${responseMessage}`);
},
};
from node_characterai.
see the main page, you'll have an example.
const CharacterAI = require('node_characterai');
const characterAI = new CharacterAI();
(async() => {
await characterAI.authenticateAsGuest();
const characterId = "8_1NyR8w1dOXmI1uWaieQcd147hecbdIK7CeEAIrdJw" // Discord moderator
const chat = await characterAI.createOrContinueChat(characterId);
const response = await chat.sendAndAwaitResponse('Hello discord mod!', true)
console.log(response);
// use response.text to use it in a string.
})();
from node_characterai.
You're kinda doing things wrong too. you should store an instance of the chat or characterai and use it per request instead of keep logging and creating new character ai instances when a message is sent
from node_characterai.
Well there isn't much documentation about how to keep the conversation going without starting a new one + the command is still very barebones and I'm just trying to see if I can get it to return anything. I'll just try the code provided in an empty js file and see if it works tomorrow
from node_characterai.
from node_characterai.
from node_characterai.
I used your example code in a blank file, and it still just fails on the lazy token. I could probably still test it in a completely new node project folder to rule out if there's any npm package conflicting with it, but I don't think that would be the case. I tried using just Chrome to go to https://beta.character.ai/chat/auth/lazy/ which does work, but it says {"detail":"Method "GET" not allowed."}. That might be normal though
node test.js
/Volumes/Stuff 8 TB/Shared/BraixenBot/node_modules/node_characterai/client.js:211
} else throw Error('Failed to fetch a lazy token')
^
Error: Failed to fetch a lazy token
at Client.authenticateAsGuest (/Volumes/Stuff 8 TB/Shared/BraixenBot/node_modules/node_characterai/client.js:211:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Volumes/Stuff 8 TB/Shared/BraixenBot/test.js:5:5
Node.js v19.7.0
from node_characterai.
I'm having the same issue with the example code. Just to check, I added a console.log(request)
inside authenticateAsGuest
, and sure enough, it returns a 403. Not sure why that's happening though.
Edit: It works when I send the same request through Postman:
from node_characterai.
403 is likely Cloudflare blocking the request, which is what I'm seeing myself when I call using this and Node.
from node_characterai.
Hello!
Try using a proxy or a VPN. Doing it worked correctly for me. Which version of the package are you using? Which version of node?
from node_characterai.
I got it to work. I just had to update node. Didn't work with v19.5.0, but works with v19.7.0. Thanks everyone!
from node_characterai.
all good then, waiting for op to confirm if the issue was caused by the same problem
from node_characterai.
all good then, waiting for op to confirm if the issue was caused by the same problem
Using Node.js v19.7.0 as seen on the other comments. What VPN do I need to use/which country do I need to connect to?
from node_characterai.
from node_characterai.
From Finland, not sure what the question about a code means.
If you're asking for my application's code, it's mentioned in the comment #13 (comment)
from node_characterai.
Using Node.js v19.7.0 as seen on the other comments. What VPN do I need to use/which country do I need to connect to?
If u don't have a VPN already, how about try Cloudflare WARP? It doesn't let you select specific country, but it's free. btw I'm in the USA and it works without a VPN.
from node_characterai.
I mean source code of the application
From Finland, not sure what the question about a code means. If you're asking for my application's code, it's mentioned in the comment #13 (comment)
from node_characterai.
If u don't have a VPN already, how about try Cloudflare WARP? It doesn't let you select specific country, but it's free. btw I'm in the USA and it works without a VPN.
Tried with Cloudflare WARP, made no difference, unfortunately. This was expected though as Cloudflare has a server in my country, so WARP just connected to that.
I mean source code of the application
test.js
Or do you need the entire project folder?
from node_characterai.
This might be a region issue (use a vpn or proxy)/nodejs version/dependencies
from node_characterai.
I tried out Windscribe to connect to US Central, still the same exact error. What version of node.js do I need and what dependencies? Shouldn't all of them be installed by npm?
from node_characterai.
I tried out Windscribe to connect to US Central, still the same exact error. What version of node.js do I need and what dependencies? Shouldn't all of them be installed by npm?
"node-fetch": "^3.3.0",
"uuid": "^9.0.0",
"json-bigint": "^1.0.0"
from node_characterai.
"node-fetch": "^3.3.0", "uuid": "^9.0.0", "json-bigint": "^1.0.0"
Checked and I seem to have all of them
piipperi@Piipperis-MacBook-Pro-13-2012 BraixenBot % npm info node-fetch version
3.3.1
piipperi@Piipperis-MacBook-Pro-13-2012 BraixenBot % npm info uuid version
9.0.0
piipperi@Piipperis-MacBook-Pro-13-2012 BraixenBot % npm info json-bigint version
1.0.0
from node_characterai.
whats your current node version and package version?
from node_characterai.
whats your current node version and package version?
I'm sorry but I've now replied with the node version 2 or 3 times. It's v19.7.0. And the package versions are listed on my earlier reply...
If you need the node_characterai version, it's the latest 1.1.0.......
from node_characterai.
Hello! Your code did not fetch a lazy token for some reason, I will investigate the issue.
from node_characterai.
Turns out its because cloudflare seems to be blocking stuff...
from node_characterai.
Hello again, I will try to find a way to go around cloudflare and update you today. Thank you for the patience!
If you have any idea in how I can go around it in the meantime, please let me know!
Roadmap issue - #14
from node_characterai.
@realcoloride After contacting w/ user K3YOMI in #1, it turns out that he fixed with adding the user agent. He sent me a copy with the patched package and it was working, but today I checked for it and it returns nothing. Here's his modified version and I have granted his permission. I hope this helps you to confirm what's going on in here.
According to his instructions, there are two step to make it work:
- fill in the the token (not access token) in
chat.js
, by replacing(TOKEN HERE)
to the token (Keep the TOKEN word)
The token can be found in the network tab of dev tool, by searching recent:
- Only
authenticateWithToken
will work (with access token), cannot login as guest
I have confirmed that it was working yesterday night, but somehow it stopped working in today. See if it works for you.
from node_characterai.
Merging all updates for 1.1.1
in a new issue: #17.
Thank you for your understanding and patience.
from node_characterai.
Related Issues (20)
- Error with history HOT 2
- Chat.sendAndAwaitResponse throws TypeError: Cannot read properties of undefined (reading 'status') HOT 4
- Chat.sendAndAwaitResponse() doesn't properly handle waiting room HOT 1
- sessionToken gone? HOT 37
- Which method should I use? HOT 2
- Add Auto Close Chromium Process in requester.js HOT 1
- Cannot statically analyse 'require(…, …)' in line 11 HOT 1
- Cannot create object HOT 1
- Cannot read properties of undefined (reading 'length')
- ProtocolError HOT 14
- Character AI - New TTS system HOT 16
- Chat history endpoints changed HOT 2
- authenticateAsGuest() fails with error: Failed to fetch a lazy token HOT 1
- is there a way to get the generated image from the ai? HOT 1
- Cannot read properties of undefined (reading 'status') HOT 7
- Feature request: Character information HOT 2
- Timeout ms HOT 7
- createOrContinueChat issue HOT 5
- module completely errors after 2 messages at relatively the same time HOT 1
- How do you install chromium? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node_characterai.