ChatGPT Utils is a library for writing your own plugins for ChatGPT. It provides helpers to kick-start your ChatGPT plugin. This is a standalone file so it can be used in user scripts or browser extensions.
Ask is a function that will call submitConversation() and getResult() Use:
await ask("Hello World!");
Return:
Hello! How can I assist you today?
SubmitConversation is a function that will write to the text input and press enter. Calls waitForReady() before writing. Does not return output from prompt.
Use:
await submitConversation(prompt);
WaitForReady is a function that will wait until ChatGPT has finished writing/outputting result.
Use:
await waitForReady();
GetResult is a function that will get the last message and return it. Calls waitForReady() before reading.
Use:
await getResult();
Return:
Hello! How can I assist you today?
OnReady is a function that will execute the callback when ChatGPT has finished writing/outputting.
Use:
onReady(() => {
console.log("ChatGPT is ready!")
});
// Or
function handleReady() {
console.log("ChatGPT is ready!");
}
onReady(handleReady);
OnSubmit is a function that will execute the callback when the user prompts chatgpt.
onSubmit((prompt) => {
console.log("User prompted: " + prompt)
});
// Or
function handleSubmit(prompt) {
console.log("User prompted: " + prompt);
}
onSubmit(handleSubmit);
OnResult is a function that will execute the callback when ChatGPT has finished writing a response.
Use:
onResult((result) => {
console.log("ChatGPT replied: " + result)
});
// Or
function handleResult(result) {
console.log("ChatGPT replied: " + result);
}
onResult(handleResult);