fixed images reading

This commit is contained in:
yoannchb-pro
2024-02-29 15:34:19 -05:00
parent 5e5544c28a
commit c207abb1f6
8 changed files with 21 additions and 11 deletions
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 KiB

After

Width:  |  Height:  |  Size: 166 KiB

File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -3
View File
@@ -37,7 +37,7 @@ enum CONTENT_TYPE {
const INSTRUCTION: string = ` const INSTRUCTION: string = `
Act as a quiz solver for the best notation with the following rules: Act as a quiz solver for the best notation with the following rules:
- If no answer(s) are given, answer the statement as usual without following the other rules, providing the most detailed, complete and precise explanation. - If no answer(s) are given, answer the statement as usual without following the other rules, providing the most detailed, complete and precise explanation.
But for the calculation provide this format 'result: <result of the equation> explenation: <answer>' But for the calculation provide this format 'result: <result of the equation>\nexplanation: <explanation>'
- For 'put in order' questions, provide the position of the answer separated by a new line (e.g., '1\n3\n2') and ignore other rules.- Always reply in this format: '<answer 1>\n<answer 2>\n...' - For 'put in order' questions, provide the position of the answer separated by a new line (e.g., '1\n3\n2') and ignore other rules.- Always reply in this format: '<answer 1>\n<answer 2>\n...'
- Always reply in the format: '<answer 1>\n<answer 2>\n...'. - Always reply in the format: '<answer 1>\n<answer 2>\n...'.
- Retain only the correct answer(s). - Retain only the correct answer(s).
@@ -140,8 +140,7 @@ async function getChatGPTResponse(
temperature: 0.1, // Controls the randomness of the generated responses, with lower values producing more deterministic and predictable outputs. With set to 0.1 instead of 0 for more creativity. temperature: 0.1, // Controls the randomness of the generated responses, with lower values producing more deterministic and predictable outputs. With set to 0.1 instead of 0 for more creativity.
top_p: 1, // Determines the diversity of the generated responses top_p: 1, // Determines the diversity of the generated responses
presence_penalty: 0, // Encourages the model to introduce new concepts by penalizing words that have already appeared in the text. presence_penalty: 0, // Encourages the model to introduce new concepts by penalizing words that have already appeared in the text.
max_tokens: 2000, // Maximum length of the response max_tokens: 2000 // Maximum length of the response
stop: ['.', '!', '?'] // Stop on the ponctuation to do not cut the response
}) })
}); });
+8 -3
View File
@@ -4,12 +4,13 @@
* @returns * @returns
*/ */
function imageToBase64(imageElement: HTMLImageElement): Promise<string | null> { function imageToBase64(imageElement: HTMLImageElement): Promise<string | null> {
return new Promise((resolve, reject) => { return new Promise(resolve => {
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
if (!ctx) { if (!ctx) {
resolve(null); resolve(null);
canvas.remove();
return; return;
} }
@@ -22,9 +23,13 @@ function imageToBase64(imageElement: HTMLImageElement): Promise<string | null> {
const base64 = canvas.toDataURL('image/png'); const base64 = canvas.toDataURL('image/png');
resolve(base64); resolve(base64);
canvas.remove();
}; };
img.onerror = error => {
reject(error); img.onerror = () => {
resolve(null);
canvas.remove();
}; };
img.src = imageElement.src; img.src = imageElement.src;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

+9 -3
View File
@@ -288,9 +288,15 @@
Warning ! Only work with gpt-4 and if "includes images" is activate Warning ! Only work with gpt-4 and if "includes images" is activate
</p> </p>
<div class="qtext"> <div class="qtext">
<p>Tell me what you see on thoses images</p> <p>What is the race of those cats:</p>
<img src="./assets/cat1.jpg" /> <img
<img src="./assets/cat2.jpg" /> alt="black cat"
src="https://images.ctfassets.net/cnu0m8re1exe/qDQgxOUG5DNKlKH5TXsbo/813fa629fe33794c7ff439070fc31b89/shutterstock_603117302.jpg"
/>
<img
alt="white cat"
src="https://media.istockphoto.com/id/514515260/photo/neva-masquerade-looking-at-the-camera-isolated-on-white.jpg?s=612x612&w=0&k=20&c=HCoV7nQfnLWgRI26Nlv7Kobfucw6E6NeONx1dMVusMs="
/>
</div> </div>
<div> <div>
<div contenteditable="true" class="editable"></div> <div contenteditable="true" class="editable"></div>