-
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
1.1+ - Roadmap (bug fixes and more) #17
Comments
Quoting Naozumi520
This will be my priority as for now, because it seems like it seems to be a root of other issues right now... Thank you for the help though, I will keep you updated |
Hello! I located some issues regarding logging in:
So far, I really need a way to go around the cloudflare issues at the moment. |
Hello, I've made a puppeteer implentation and it turns out that even with plugins such as the stealth plugin, the request seem to work only when not headless. (so chrome needs to appear, this may be annoying and more resource eating on lower end machines) I will check out selenium as recommended by some people and friends of mine. I will keep you updated! |
Alright for now, I will use a temporary fix that uses headful chrome. |
For I will keep you updated! |
What about linux users? like myself. i only have access to a terminal. |
Yes I had thought of this part too, I work on Windows and don't know how to use pupeteer on Linux. |
Getting undefined when logging in with a token (guest login did not work). const response = await chat.sendAndAwaitResponse('Hi', true) Happy to help testing, I have a proxy service I can try and also have some experience with puppeteer. Thanks for the helpful project! |
Hey! Sorry if this is a redundant question but I just wanted to ask, will 1.1.1 have a fix for the Status 403 error(At least I think that's the error from reading through the old issues, its the same error as the comment above) on Linux? Its what I run my server on, so hopefully you can figure something out haha. Also, thanks for picking up this project! |
I'm aware of the issues.
To answer it all: cloudflare.
Cloudflare blocks the requests at the moment, see up and other issues.
Which breaks the lib completely.
At the moment, I'm doing my best to find the best way to go around
cloudflare protection.
For such, the best at the moment is a chromium browser using puppeteer.
Le mer. 15 mars 2023 à 05:02, feelin__sleepy ***@***.***> a
écrit :
… Hey! Sorry if this is a redundant question but I just wanted to ask, will
1.1.1 have a fix for the Status 403 error(At least I think that's the error
from reading through the old issues, its the same error as the comment
above) on Linux? Its what I run my server on, so hopefully you can figure
something out haha. Also, thanks for picking up this project!
—
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZ4WO5LNDLLA75V3HIXPVKDW4E5NBANCNFSM6AAAAAAV2UBEL4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@realcoloride The way to fix the issue is simple:
|
It's now working with headless mode. |
Decided to try this real quick before I went to work, no luck, just says "page" in "page.setUserAgent(userAgent);" is undefined. Could definitely be an issue on my end though with my code being wonky. |
This isn't mean for the original package. OP used the puppeteer tricks to bypass the Cloudflare service. And I'm currently using my own code to get the response with puppeteer. So you cannot just add it to the package. |
Ohhh. Gotcha, sorry about that |
But as soon as OP updated the code with my trick, it should be just working fine! |
Ok after fiddling around a little more, I've found out how to get around it succesfully. Thank you for the help @Naozumi520! |
This is how I'm currently doing: page.on('response', async (response) => {
try {
if (response.url() == "https://beta.character.ai/chat/streaming/") {
const text = await response.text()
// the last choke, which is "lastchoke": true
let raw = text.trim().split('"replies": [{"text":')[text.trim().split('"replies": [{"text":').length - 1];
raw = raw.split(', "id":')[0].trim()
const emojiRegex = /\\u([\dA-Fa-f]{4})/g;
const reply = raw.substring(1, raw.length - 1).replaceAll('↵', ', ').replaceAll('\\n', '').replaceAll('\\"', '"')
const decodedText = reply.replaceAll(emojiRegex, (match, grp) => String.fromCharCode(parseInt(grp, 16)));
console.log(decodedText)
}
} catch (e) {
console.log(e)
}
}); It's very dirty indeed 😓 |
@Naozumi520 I might use your code and modify some stuff until I can find a viable better solution. Then probably push an experimental update after im done doing a few stuff. |
@Naozumi520 Hello, Here is my current sample code, could you be more precise please? async request(url, options) {
const page = this.page;
const method =
(options.method == 'POST' || options.method == undefined || options.method == null
? 'POST' : 'GET');
const body = (method == 'GET' ? {} : options.body);
const headers = options.headers;
page.once('request', interceptedRequest => {
var data = {
'method': method,
'postData': body,
'headers': headers
};
try {
interceptedRequest.continue(data);
} catch (error) {
console.log("[node_characterai] Puppeteer - Non fatal error: " + error);
}
});
page.on('response', async (response) => {
// thank you Naozumi520 for this piece of code
try {
if (response.url() == "https://beta.character.ai/chat/streaming/") {
const text = await response.text()
// the last choke, which is "lastchoke": true
let raw = text.trim().split('"replies": [{"text":')[text.trim().split('"replies": [{"text":').length - 1];
raw = raw.split(', "id":')[0].trim()
const emojiRegex = /\\u([\dA-Fa-f]{4})/g;
const reply = raw.substring(1, raw.length - 1).replaceAll('↵', ', ').replaceAll('\\n', '').replaceAll('\\"', '"')
const decodedText = reply.replaceAll(emojiRegex, (match, grp) => String.fromCharCode(parseInt(grp, 16)));
console.log(decodedText)
}
} catch (e) {
console.log(e)
}
});
let response
try {
response = await page.goto(url, { waitUntil: 'networkidle0' });
} catch (error) {
console.log("[node_characterai] Puppeteer - " + error)
}
return response;
} |
Sure I will check for it! But I have lessons soon, I will report the result later. |
Hi! Would you mind sending me your currently testing code, so I can make a test with it? Edit: My discord is "Naozumi#0233" |
Hello everyone, I am looking forward to polish the next updates that come for 1.1+. The only limitations for now is that you must use a headful puppeteer. |
I got your code to work in headless by adding |
Yes, it works! 🤯 |
Can confirm headless works and will be pushed to the main branch now. Many thanks to @saki64 |
Experimental update Please let me know how this update goes! |
It's working really well so far! Great work on figuring this out. One thing I noticed was it seems like search for characters is now allowed for guests (worked just by removing the guest check). Wondering if anything else is now guest enabled that wasn't before as well.
|
Hello and thanks for the feedback! I will take in consideration that. Because beforehand, it was a logged in only feature. Also, I'm pretty sure the |
Hello! Also, POLL: Do you think a documentation is needed? |
Hello, I am planning to push the update 1.1.4, an experimental update to add new features like the new puppeteer headless version, executable path, cloudflare waiting room, and image utilities. I will make a roadmap to keep you updated and link issues. |
1.1.4+ roadmap:
|
Hello everyone, I've spotted an issue where chromium tabs would be left open when closing the program. I will investigate the issue and resolve it. |
Experimental version
Happy coding! |
Just to make sure, is it possible to get this working on a Raspberry Pi? It seems like it won't due to, according to Puppeteer, the architecture being different and unsupported by Chromium. Though, at the same time, I've heard about Puppeteer running fine on a RPi with a few tweaks. Do you have any insight you can give? |
Hello, I don't really know as I don't use Linux neither raspberry pi, but I think that it should be fine because chromium is supported on most platforms. Maybe try tweaking things but I can't help much sadly. |
Ah, I suppose "Here be dragons" haha. I'll definitely keep tweaking, it should be possible, I suppose the issue is I just don't know where to make the tweaks at. I'm looking for this API's equivalent of this code example : "const puppeteer = require('puppeteer'); (async () => { await browser.close(); Basically, where Puppeteer gets initiated it seems. I need to change some settings about where it runs Chromium from as far as I can tell. Do you know where I might be able to find it? Many thanks for any help. |
see README.md for information, "in depth troubleshooting". |
Perfect! I'm not sure how I missed it- thanks for the help! |
Closed in relevance for 1.2+ versions, do not hesitate to open an issue if something is needed. |
[Roadmap] Sum up of update goals: (from issue #14, merged here)
This will be updated overtime.
The text was updated successfully, but these errors were encountered: