more dumb mistakes
This commit is contained in:
parent
7c3cfe879f
commit
b308a75452
1 changed files with 54 additions and 59 deletions
53
index.mjs
53
index.mjs
|
@ -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;
|
||||
}
|
||||
|
@ -194,9 +192,9 @@ async function generateModelfile(c) {
|
|||
for (const item of c) {
|
||||
try {
|
||||
ags_modelfile += createContextPart(`${JSON.stringify(item)}`);
|
||||
} catch {} //very hacky.
|
||||
} 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()]);
|
||||
|
|
Loading…
Reference in a new issue