Skip to content
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

New OpenAI model update solution #252

Open
hoshizorista opened this issue Jul 25, 2024 · 10 comments
Open

New OpenAI model update solution #252

hoshizorista opened this issue Jul 25, 2024 · 10 comments

Comments

@hoshizorista
Copy link

hoshizorista commented Jul 25, 2024

Hey guys! again OpenAI changed its selectors for chatgpt and broke the extension, I managed to fixed it, check out the fork I made at my profile, well work to keep it updated and bring some cool new functions in the near future

If you dont really want to check the fork and youre a bit code-wise heres the updated functions u need to change on content.js to update it:

1st, look for function CN_CheckNewMessages() and replace the entire function with:

// Check for new messages the bot has sent. If a new message is found, it will be read out loud
function CN_CheckNewMessages() {
	// Any new messages?
	var currentMessageCount = document.querySelectorAll('.text-message').length
	if (currentMessageCount > CN_MESSAGE_COUNT) {
		// New message!
		console.log("New message detected! current message count: " + currentMessageCount);
		CN_MESSAGE_COUNT = currentMessageCount;
		CN_CURRENT_MESSAGE = document.querySelectorAll('.text-message')[currentMessageCount - 1];
		CN_CURRENT_MESSAGE_SENTENCES = []; // Reset list of parts already spoken
		CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ = 0;
	}
	
	// Split current message into parts
	if (CN_CURRENT_MESSAGE) {
		var currentText = document.querySelectorAll('.text-message')[currentMessageCount - 1].innerText + "";
		//console.log("currentText:" + currentText);

		
		// Remove code blocks?
		if (CN_IGNORE_CODE_BLOCKS) {
			currentText = ""
			document.querySelectorAll('.text-message')[currentMessageCount - 1].querySelectorAll(".markdown > :not(pre)").forEach(n => {
				currentText += n.innerText
			});
			////console.log("[CODE] currentText:" + currentText);
		}
		
		var newSentences = CN_SplitIntoSentences(currentText);
		if (newSentences != null && newSentences.length != CN_CURRENT_MESSAGE_SENTENCES.length) {
			////console.log("[NEW SENTENCES] newSentences:" + newSentences.length);
			
			// There is a new part of a sentence!
			var nextRead = CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ;
			for (let i = nextRead; i < newSentences.length; i++) {
				CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ = i+1;

				var lastPart = newSentences[i];
				//console.log("Will say sentence out loud: "+lastPart);
				CN_SayOutLoud(lastPart);
			}
			CN_CURRENT_MESSAGE_SENTENCES = newSentences;
		}
	}
	
	
	setTimeout(CN_CheckNewMessages, 100);
}

2nd: look for var currentMessageCount = document.querySelectorAll('.text-base .items-start').length; and replace it with

		var currentMessageCount = document.querySelectorAll('.text-message').length;

@hoshizorista
Copy link
Author

btw for the messages not being auto send after speech to text, just look for the comment

// Find the send button and enable it

and change the code bellow the comment to

var sendButton = jQuery("[data-testid='send-button']"); 
    if (sendButton.length) {
        sendButton.prop('disabled', false); // Force enable
        sendButton.removeAttr('disabled').removeClass('disabled');

        // Ensure the button is enabled and click it
        if (!sendButton.is(':disabled')) {
            sendButton[0].click(); // Attempt to click using DOM API
            console.log("[CN_SendMessage] Automatically clicking the send button.");
        } else {
            console.log("[CN_SendMessage] The send button is enabled but could not be clicked.");
        }
    } else {
        console.error("[CN_SendMessage] Send button not found.");
    }

@deadbydonovan
Copy link

deadbydonovan commented Jul 25, 2024

@hoshizorista thank you so much, but we have a new problem. Elevenlabs has changed their API keys and the new key generations don't work with this extension, I keep getting errors, ChatGPT Says [1] ElevenLabs API error: Invalid API key.
I accessed an old ElevenLabs account of mine to use the old API key and it works fine. Any ideas? I have half a million characters locked up with the new API.

@hoshizorista
Copy link
Author

@deadbydonovan not really familiar with those new API keys, do they seem longer? anything particullary changed from older to newest? if you have discord lmk so i can hit you up and help you with that

i tried with my usual api key and works ok

@deadbydonovan
Copy link

deadbydonovan commented Jul 25, 2024

@hoshizorista the new API Keys start with "sk_" followed by a bunch of numbers. I have a discord

@hoshizorista
Copy link
Author

@hoshizorista the new API Keys start with "sk_" followed by a bunch of numbers. I have a discord

hmu on discord: exile9904

@deadbydonovan
Copy link

@hoshizorista I don't really know how to use Discord, but here's a server I just created to chat. https://discord.gg/kP3ssNCw or message me an invite, sorry I'm new to this.

@hoshizorista
Copy link
Author

for anyone having this same error with newest ElevenLabs TTS, just go to

CN_TTS_ELEVENLABS_APIKEY = CN_RemovePunctuation(jQuery("#TTGPTElevenLabsKey").val()+"");

and replace it with

CN_TTS_ELEVENLABS_APIKEY = jQuery("#TTGPTElevenLabsKey").val()+"";

@hoshizorista
Copy link
Author

(or just download the extension available at my fork)

@StudioDweller
Copy link

Thank you so much for maintaining this! I have a podcast about AI and we rely on it for realtime interaction with our custom GPT-based AI co-host. We are recording our next episode later today and will be sure to give you a shoutout (again). The Up Against Reality podcast really appreciates all of your efforts!

@enrix507
Copy link

Hey guys! again OpenAI changed its selectors for chatgpt and broke the extension, I managed to fixed it, check out the fork I made at my profile, well work to keep it updated and bring some cool new functions in the near future

If you dont really want to check the fork and youre a bit code-wise heres the updated functions u need to change on content.js to update it:

1st, look for function CN_CheckNewMessages() and replace the entire function with:

// Check for new messages the bot has sent. If a new message is found, it will be read out loud
function CN_CheckNewMessages() {
	// Any new messages?
	var currentMessageCount = document.querySelectorAll('.text-message').length
	if (currentMessageCount > CN_MESSAGE_COUNT) {
		// New message!
		console.log("New message detected! current message count: " + currentMessageCount);
		CN_MESSAGE_COUNT = currentMessageCount;
		CN_CURRENT_MESSAGE = document.querySelectorAll('.text-message')[currentMessageCount - 1];
		CN_CURRENT_MESSAGE_SENTENCES = []; // Reset list of parts already spoken
		CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ = 0;
	}
	
	// Split current message into parts
	if (CN_CURRENT_MESSAGE) {
		var currentText = document.querySelectorAll('.text-message')[currentMessageCount - 1].innerText + "";
		//console.log("currentText:" + currentText);

		
		// Remove code blocks?
		if (CN_IGNORE_CODE_BLOCKS) {
			currentText = ""
			document.querySelectorAll('.text-message')[currentMessageCount - 1].querySelectorAll(".markdown > :not(pre)").forEach(n => {
				currentText += n.innerText
			});
			////console.log("[CODE] currentText:" + currentText);
		}
		
		var newSentences = CN_SplitIntoSentences(currentText);
		if (newSentences != null && newSentences.length != CN_CURRENT_MESSAGE_SENTENCES.length) {
			////console.log("[NEW SENTENCES] newSentences:" + newSentences.length);
			
			// There is a new part of a sentence!
			var nextRead = CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ;
			for (let i = nextRead; i < newSentences.length; i++) {
				CN_CURRENT_MESSAGE_SENTENCES_NEXT_READ = i+1;

				var lastPart = newSentences[i];
				//console.log("Will say sentence out loud: "+lastPart);
				CN_SayOutLoud(lastPart);
			}
			CN_CURRENT_MESSAGE_SENTENCES = newSentences;
		}
	}
	
	
	setTimeout(CN_CheckNewMessages, 100);
}

2nd: look for var currentMessageCount = document.querySelectorAll('.text-base .items-start').length; and replace it with

		var currentMessageCount = document.querySelectorAll('.text-message').length;

thank very much amigo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants