v1.0.3
This commit is contained in:
@@ -45,12 +45,13 @@ function setUpMoodleGpt(config: Config) {
|
||||
.map((e) => `input[type="${e}"]`)
|
||||
.join(",");
|
||||
const query = inputQuery + ", textarea, select, [contenteditable]";
|
||||
const forms = Array.from(document.querySelectorAll(".formulation"));
|
||||
const forms = document.querySelectorAll(".formulation");
|
||||
|
||||
for (const form of forms) {
|
||||
const hiddenButton: HTMLElement = form.querySelector(".qtext");
|
||||
|
||||
if (config.cursor) hiddenButton.style.cursor = "pointer";
|
||||
|
||||
const fn = reply.bind(null, config, hiddenButton, form, query);
|
||||
listeners.push({ element: hiddenButton, fn });
|
||||
hiddenButton.addEventListener("click", fn, { once: !config.infinite });
|
||||
|
||||
@@ -21,7 +21,7 @@ function createQuestion(config: Config, questionContainer: HTMLElement) {
|
||||
);
|
||||
}
|
||||
|
||||
const finalQuestion = `Give a short response as possible for this question, reply in the following question langage and only show the result:
|
||||
const finalQuestion = `Give a short response as possible for this question, reply in the following question langage and only show the result:
|
||||
${question}
|
||||
(If you have to choose between multiple results only show the corrects one, separate them with new line and take the same text as the question)`;
|
||||
return normalizeText(finalQuestion);
|
||||
|
||||
+9
-2
@@ -33,11 +33,18 @@ async function reply(
|
||||
error,
|
||||
})
|
||||
);
|
||||
const haveError = typeof response === "object" && "error" in response;
|
||||
const isAbortError = haveError && response.error.name === "AbortError";
|
||||
|
||||
if (config.cursor)
|
||||
hiddenButton.style.cursor = config.infinite ? "pointer" : "initial";
|
||||
hiddenButton.style.cursor =
|
||||
config.infinite || isAbortError ? "pointer" : "initial";
|
||||
|
||||
if (haveError) {
|
||||
if (isAbortError) {
|
||||
//TODO: We need to inject back the event
|
||||
}
|
||||
|
||||
if (typeof response === "object" && "error" in response) {
|
||||
console.error(response.error);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user