more dumb mistakes

This commit is contained in:
The Ghost of FOSS' Past 2024-10-02 16:43:11 -05:00
parent 7c3cfe879f
commit b308a75452

View file

@ -22,16 +22,16 @@ const modelID = "local-agsamantha"
const maxDepthCount = 11
function ask(q) {
let ans = "";
return new Promise((resolve) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question(q, a => {
ans = a
rl.close();
resolve(a);
});
});
return ans
}
// Function to run the publishing commands
@ -60,7 +60,6 @@ async function runPublishCommands() {
}
}
const ags_template_part1 = ` # base systems
FROM deepseek-coder
FROM dolphin-mistral
@ -147,8 +146,7 @@ ${c}
}
function generateSearchTerm(hostname) {
//return `https://search.sparksammy.com/search.php?q=site%3A${encodeURIComponent(String(hostname))}&p=0&t=0`
return `http://${hostname}`
return `http://${hostname}`;
}
const contexts = [];
@ -169,12 +167,12 @@ async function siteCrawler(hostname) {
return webContents;
} catch (error) {
console.error(`Failed to crawl site ${hostname}:`, error);
return webContents || [];
return [];
}
}
async function contextAdd(hostnames) {
const promises = hostnames.map(hostname => siteCrawler(hostname) || "ERROR CRAWLING THIS SITE. IGNORE THIS DOCUMENT.");
const promises = hostnames.map(hostname => siteCrawler(hostname));
await Promise.all(promises);
return contexts;
}
@ -184,9 +182,9 @@ let userAGIInput = `
`;
async function generateModelfile(c) {
let ags_modelfile = ""
let ags_modelfile;
try {
const ags_modelfile = await readFile(`${systemSavePath}`, { encoding: 'utf8' });
ags_modelfile = await readFile(systemSavePath, { encoding: 'utf8' }) || ags_template_part1;
} catch (err) {
ags_modelfile = ags_template_part1;
}
@ -196,7 +194,7 @@ async function generateModelfile(c) {
ags_modelfile += createContextPart(`${JSON.stringify(item)}`);
} catch {} // very hacky.
}
ags_modelfile += createUserContextPart(userAGIInput)
ags_modelfile += createUserContextPart(userAGIInput);
await writeFile(systemSavePath, ags_modelfile)
.then(() => {
console.log('File written successfully!');
@ -216,16 +214,15 @@ async function generateModelfile(c) {
async function learner() {
try {
await contextAdd(["en.wikipedia.org", "toontownrewritten.wiki", "rezero.fandom.com", "fategrandorder.fandom.com"]);
await contextAdd(["68k.news"])
await contextAdd(["68k.news"]);
await contextAdd(["old.reddit.com"]);
//await contextAdd(["tea.texas.gov/student-assessment/staar/released-test-questions/2024-staar-algebra-i-answer-key.pdf", "tea.texas.gov/student-assessment/staar/released-test-questions/2024-staar-english-ii-answer-key.pdf", "tea.texas.gov/student-assessment/staar/released-test-questions/2024-staar-biology-answer-key.pdf", "tea.texas.gov/student-assessment/staar/released-test-questions/2024-staar-us-history-answer-key.pdf"])
const modelfile = await generateModelfile(contexts);
console.log(modelfile);
runPublishCommands();
return 0
await runPublishCommands();
return 0;
} catch (error) {
console.error("Error in main function:", error);
return 1
return 1;
}
}
@ -233,29 +230,27 @@ const delay = ms => new Promise(res => setTimeout(res, ms));
async function learningLoop() {
while (true) {
await main()
await delay(60000*20) //20 minutes in ms.
await learner();
await delay(60000 * 20); // 20 minutes in ms.
}
}
async function talkLoop() {
while (true) {
let q = await ask(`To ${modelID}: `)
userAGIInput += await `
let q = await ask(`To ${modelID}: `);
userAGIInput += `
USER: ${q}`;
let a = await ollama.chat({
model: `${modelID}`,
messages: [{ role: 'user', content: `${q}` }],
})
userAGIInput += await `
});
userAGIInput += `
AI: ${a.message.content}`;
console.log(`${a.message.content}`)
generateModelfile(contexts)
runPublishCommands()
console.log(`${a.message.content}`);
await generateModelfile(contexts);
await runPublishCommands();
}
}
Promise.allSettled([learningLoop(), talkLoop()])
Promise.allSettled([learningLoop(), talkLoop()]);