This commit is contained in:
yoannchb-pro
2023-03-24 14:00:23 -04:00
parent 868e4bcbde
commit b8e1d35188
5 changed files with 18 additions and 17 deletions
+4 -7
View File
@@ -54,13 +54,10 @@ Type back the <b>code</b> on the keyboard and the code will be removed from the
- <b>Table formatting</b>: Format table from the question to make it more readable for CHAT-GPT but cost most tokens (so if the question is too large it will make an error). Example of formatted table:
```
--------------------------------
| |name |birthDate |cars|
--------------------------------
|Person 1|Yvick|15/08/1999|yes |
--------------------------------
|Person 2|Yann |19/01/2000|no |
--------------------------------
| id | name | birthDate | cars |
--------------------------------------
| Person 1 | Yvick| 15/08/1999 | yes |
| Person 2 | Yann | 19/01/2000 | no |
```
- <b>Infinite try</b>: click as much as you want on the question (don't forget to reset the question).
+5 -4
View File
@@ -121,14 +121,15 @@
});
tab.push(cellsContent);
});
const lineSeparationSize = maxColumnsLength.reduce((a, b) => a + b) + tab[0].length + 1;
const lineSeparationSize = maxColumnsLength.reduce((a, b) => a + b) + tab[0].length * 3 + 1;
const lineSeparation = "\n" + Array(lineSeparationSize).fill("-").join("") + "\n";
const mappedTab = tab.map((line) => {
const mappedLine = line.map((content, index) => content.padEnd(maxColumnsLength[index], "\u00A0") //for no matching with \s
);
return "|" + mappedLine.join("|") + "|";
return "| " + mappedLine.join(" | ") + " |";
});
return lineSeparation + mappedTab.join(lineSeparation) + lineSeparation;
const head = mappedTab.shift();
return head + lineSeparation + mappedTab.join("\n");
}
/**
@@ -143,7 +144,7 @@
//make table more readable for chat-gpt
const tables = questionContainer.querySelectorAll(".qtext table");
for (const table of tables) {
question = question.replace(table.textContent, htmlTableToString(table));
question = question.replace(table.textContent, "\n" + htmlTableToString(table) + "\n");
}
}
const finalQuestion = `Give a short response as possible for this question, reply in ${config.langage && config.langage !== ""
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -16,7 +16,10 @@ function normalizeQuestion(config: Config, questionContainer: HTMLElement) {
const tables: NodeListOf<HTMLTableElement> =
questionContainer.querySelectorAll(".qtext table");
for (const table of tables) {
question = question.replace(table.textContent, htmlTableToString(table));
question = question.replace(
table.textContent,
"\n" + htmlTableToString(table) + "\n"
);
}
}
+4 -4
View File
@@ -21,7 +21,7 @@ function htmlTableToString(table: HTMLTableElement) {
});
const lineSeparationSize =
maxColumnsLength.reduce((a, b) => a + b) + tab[0].length + 1;
maxColumnsLength.reduce((a, b) => a + b) + tab[0].length * 3 + 1;
const lineSeparation =
"\n" + Array(lineSeparationSize).fill("-").join("") + "\n";
@@ -29,10 +29,10 @@ function htmlTableToString(table: HTMLTableElement) {
const mappedLine = line.map(
(content, index) => content.padEnd(maxColumnsLength[index], "\u00A0") //for no matching with \s
);
return "|" + mappedLine.join("|") + "|";
return "| " + mappedLine.join(" | ") + " |";
});
return lineSeparation + mappedTab.join(lineSeparation) + lineSeparation;
const head = mappedTab.shift();
return head + lineSeparation + mappedTab.join("\n");
}
export default htmlTableToString;