realcoloride/node_characterai

#Client.generateImage() result link appears to be unavailable

Hadestia opened this issue · 6 comments

Hello, I attempted to utilize this function, however it appears the returnable URL is routinely closed or deleted upon retrieval, resulting in an error 404 advising the page is unavailable. When I attempted to view the returned URL via my browser, it rendered a similar outcome. Is there a possibility of a faulty parameter?
Screenshot_20240129-182935_1

Hello, could you show me your code?

I was wrong it's because of the cloudflare not letting my fetcher to get the image data. Is there should be a possibility that we could do 'pipe' the returned link?

Sorry I'm developing with my Android
Screenshot_20240129-185615_1
but here's my code, while 'Utils.downloadFile' was just an 'Axios.get()' function

Hello, your code seem correct, but perhaps downloadFile is faulty. Try to open the generated image in characterai's UI and your browser and see if they show up correctly. If not, try analyzing the chromium's browser requests. set headless to false and search for the generate request in the Network tab and see the response you get.

Good luck and keep me updated!

Hi, I can now see the image on my local browser after Cloudflare verification
. I tried to make a 'GET' request with Axios and use the headers from the client as shown below, still no progress giving the same output and by the way i forgot to mention that my server was via cloud hosting.

//CLIENT AUTHENTICATION
module.exports.authenticate = async function (root) {
	
	const characters = Filesystem.readJsonSync(Path.join(root, 'json', '/ref-characterAI.json'));
	const models = { isError: false };
	
	try {
		for (const name in characters) {
			const characterAI = new CharacterAI();
			await characterAI.authenticateWithToken(accessToken, idToken);
			const chat = await characterAI.createOrContinueChat(characters[name]);
			models[name] = { chat, client: characterAI }
		}
	} catch (err) {
		models.isError = true;
	}
	
	return models
}
/// Use Script
const path = Path.join(CLIENT.CACHE_PATH, `genImage-${Date.now()}-${messageID}.jpg`);
await Axios.get(
	result, 
	{ 
		responseType: 'arrayBuffer',
		headers: CharacterAI.AlyannaRoom.client.getHeaders()
	}
).then((response) => {
	Filesystem.writeFileSync(path, Buffer.from(response.data, 'utf-8'));
	attachment[0] = Filesystem.createReadStream(path);
	reply({ text: '' }, path);
}).catch((err) => {
	Logger.makeLog(CLIENT.LOG_PATH, `${ModuleData.id}: Unable to download image from the request with ${err}`, 'warn');
	Message.react('error');
});

Hello, the image uploading features were rewritten since.

Feel free to re open an issue or this one if you encounter more or the same problem.
Cheers.