console.log("coding, this will take a bit of time!");
functionlangExec(langCode){
if(lang=="js"){
returneval(langCode);
}elseif(lang=="python"||lang=="ppython"){
constpythonProcess=spawn(lang,['-c',langCode]);
returnnewPromise((resolve,reject)=>{
letoutput='';
pythonProcess.stdout.on('data',(data)=>{
output+=data.toString();
});
pythonProcess.stderr.on('data',(data)=>{
reject(data.toString());
});
pythonProcess.on('close',(code)=>{
if(code===0){
resolve(output);
}else{
reject(`Process exited with code ${code}`);
}
});
});
}else{
console.error("Language command not found!")
}
}
functiongetLangID(){
if(lang=="ppython"){
return"panda3d python"
}else{
returnlang;
}
}
functionreplaceAll(str,find,replace){
returnstr.replace(newRegExp(find,'g'),replace);
}
asyncfunctionmain(){
constinstance=newOllama({
model:"codellama",
url:"http://127.0.0.1:11434/api/",
});
letanswer=awaitinstance.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.`);
answer=awaitinstance.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.`)
}
}
return1;
}
asyncfunctionaThousand(){
constinstance=newOllama({
model:"codellama",
url:"http://127.0.0.1:11434/api/",
});
letpotentialAnswersQuestion=`Which answer is best suited for ${problem}?