This commit is contained in:
yoannchb-pro
2023-06-19 23:08:04 -04:00
parent 47b239ae54
commit 9dfe7acc58
6 changed files with 22 additions and 11 deletions
+2 -2
View File
@@ -2,12 +2,12 @@
## Priority: 1
- [ ] Fixe `normalizeText` (line break are sometimes removed for nothing e.g: checkbox)
- [ ] Support math equation from image stocked in the `data-mathml` attribute
- [ ] Increment question when there is statement
- [ ] Allow click back on question if timeout
## Priority: 3 (because hard to make)
- [ ] Support math equation from image stocked in the `data-mathml` attribute
- [ ] Try something to understand images like (image -> ascii or may be using other AI ?)
- [ ] Support multiple input type in a question
- [ ] Support drag and drop quiz
+7 -4
View File
@@ -145,7 +145,7 @@
for (const table of tables) {
question = question.replace(table.innerText, "\n" + htmlTableToString(table) + "\n");
}
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);
@@ -368,9 +368,12 @@
const response = yield getChatGPTResponse(config, question).catch((error) => ({
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";
if (typeof response === "object" && "error" in response) {
hiddenButton.style.cursor =
config.infinite || isAbortError ? "pointer" : "initial";
if (haveError) {
console.error(response.error);
return;
}
@@ -449,7 +452,7 @@
.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 = form.querySelector(".qtext");
if (config.cursor)
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -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 });
+1 -1
View File
@@ -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
View File
@@ -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;
}