Update 'index.js'
This commit is contained in:
parent
f304a9147f
commit
65945a4c20
1 changed files with 31 additions and 8 deletions
39
index.js
39
index.js
|
@ -2,9 +2,9 @@ import readline from 'readline';
|
||||||
import Ollama from 'ollama-js-client';
|
import Ollama from 'ollama-js-client';
|
||||||
import spawn from 'child_process';
|
import spawn from 'child_process';
|
||||||
|
|
||||||
var answerParsed = ""
|
|
||||||
|
|
||||||
let generation = 1;
|
let generation = 1;
|
||||||
|
let potentialAnswers = [];
|
||||||
|
|
||||||
|
|
||||||
function prompt(q) {
|
function prompt(q) {
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
|
@ -62,7 +62,7 @@ function getLangID() {
|
||||||
let answer = await instance.prompt(`${problem} - This must be coded in pure ${getLangID()}, no external libraries or requirements. Please provide the code, the full code, and nothing but the code. No chit-chat, no markdown, just code.`);
|
let answer = await instance.prompt(`${problem} - This must be coded in pure ${getLangID()}, no external libraries or requirements. Please provide the code, the full code, and nothing but the code. No chit-chat, no markdown, just code.`);
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
let answerParsed = ""
|
||||||
let problemSolved = false;
|
let problemSolved = false;
|
||||||
while (problemSolved == false) {
|
while (problemSolved == false) {
|
||||||
try {
|
try {
|
||||||
|
@ -76,10 +76,33 @@ async function main() {
|
||||||
answer = await instance.prompt(`There was an error: ${error.message}. Please only provide the code, the full code, and nothing but the code. No chit-chat, no markdown, just code. Also, make sure it's written in ${getLangID()} without any libraries besides included.`)
|
answer = await instance.prompt(`There was an error: ${error.message}. Please only provide the code, the full code, and nothing but the code. No chit-chat, no markdown, just code. Also, make sure it's written in ${getLangID()} without any libraries besides included.`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return answerParsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
main().then(() => {
|
async function aThousand() {
|
||||||
console.log(`!!!ANSWER COMPUTED!!!
|
let potentialAnswersQuestion = `Which answer is best suited for ${problem}?
|
||||||
|
If there are two or more answers that are about as equal, but one has lower quality code, choose the one with higher quality code.
|
||||||
${answerParsed}`);
|
Pick ONLY ONE ANSWER.
|
||||||
});
|
|
||||||
|
Answers:
|
||||||
|
|
||||||
|
`
|
||||||
|
for (let i = 0; i < 1000; i++) {
|
||||||
|
let potentialAnswer = await main();
|
||||||
|
potentialAnswers.push(potentialAnswer)
|
||||||
|
}
|
||||||
|
potentialAnswers.forEach((answer, index) => {
|
||||||
|
potentialAnswersQuestion += `
|
||||||
|
----
|
||||||
|
Answer ${index + 1}:
|
||||||
|
${answer}
|
||||||
|
----
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
let finalAnswer = await instance.prompt(`${potentialAnswersQuestion}`)
|
||||||
|
let finalAnswerParsed = finalAnswer.response;
|
||||||
|
return finalAnswerParsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
let a = await aThousand();
|
||||||
|
console.log(a)
|
||||||
|
|
Loading…
Reference in a new issue