-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tokens don't work #13
Comments
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.
|
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.
})(); |
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 |
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 |
You have to think of a way to continue that conversation from what the
library gives you, not the other way around
What you can do is create a character instance and log it in when the bot
logs in and store that character ai instance in a variable that you can
access in your command script
Then you create a conversation with the character you wish next to it
(don't forget the asynchronous context) because your bot seem to be based
around one character and store that chat
And upon the command triggers, you get that chat and send a message to the
character.
Le mer. 8 mars 2023 à 20:58, Piipperi ***@***.***> a écrit :
… 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
—
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZ4WO5L5TCBVH5UEDM4P6NLW3DQFLANCNFSM6AAAAAAVTVYPKA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Also you seem to have put responseMessage to "", was this intended?
Le jeu. 9 mars 2023 à 07:32, Coloride Youtube ***@***.***> a
écrit :
… You have to think of a way to continue that conversation from what the
library gives you, not the other way around
What you can do is create a character instance and log it in when the bot
logs in and store that character ai instance in a variable that you can
access in your command script
Then you create a conversation with the character you wish next to it
(don't forget the asynchronous context) because your bot seem to be based
around one character and store that chat
And upon the command triggers, you get that chat and send a message to the
character.
Le mer. 8 mars 2023 à 20:58, Piipperi ***@***.***> a écrit :
> 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
>
> —
> Reply to this email directly, view it on GitHub
> <#13 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AZ4WO5L5TCBVH5UEDM4P6NLW3DQFLANCNFSM6AAAAAAVTVYPKA>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
|
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
|
403 is likely Cloudflare blocking the request, which is what I'm seeing myself when I call using this and Node. |
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! |
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? |
Where are you from and what's your code?
Le ven. 10 mars 2023 à 05:37, Piipperi ***@***.***> a écrit :
… 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?
—
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZ4WO5MHMK24FMCPTUAUVMLW3KVXXANCNFSM6AAAAAAVTVYPKA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
From Finland, not sure what the question about a code means. |
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. |
I mean source code of the application
|
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.
test.js |
This might be a region issue (use a vpn or proxy)/nodejs version/dependencies |
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? |
|
Checked and I seem to have all of them
|
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... |
Hello again, I will try to find a way to go around cloudflare and update you today. Thank you for the patience! |
@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:
I have confirmed that it was working yesterday night, but somehow it stopped working in today. See if it works for you. |
Merging all updates for |
I've tried using the
authenticateAsGuest()
method, which gives meError: Failed to fetch a lazy token
.authenticateWithToken()
throws an Error:Token is invalid.
I copied the access_token without the access_token:, and I tried it twice to make sure I hadn't copied the wrong line or hadn't copied the entire token as it is very long.
Console doesn't seem to give any more specific information. Using Node v19.7.0 on macOS 12.6.3.
The text was updated successfully, but these errors were encountered: