Merge pull request 'Project Thousand: Loop the feedback loop 1000 times and have the AI choose the ultimate answer.' (#1) from project-thousand into main

Reviewed-on: http://nodemixaholic.com:3002/nodemixaholic/kode/pulls/1
This commit is contained in:
nodemixaholic 2024-03-15 20:09:03 +00:00
commit e27a3d38fa

View file

@ -2,9 +2,9 @@ import readline from 'readline';
import Ollama from 'ollama-js-client';
import spawn from 'child_process';
var answerParsed = ""
let generation = 1;
let potentialAnswers = [];
function prompt(q) {
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.`);
async function main() {
let answerParsed = ""
let problemSolved = false;
while (problemSolved == false) {
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.`)
}
}
return answerParsed;
}
main().then(() => {
console.log(`!!!ANSWER COMPUTED!!!
async function aThousand() {
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.
Pick ONLY ONE ANSWER.
${answerParsed}`);
});
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)