OH CHRIST

This commit is contained in:
The Ghost of FOSS' Past 2024-10-02 17:16:37 -05:00
parent 1616722f3b
commit 2d342f9aaa

View file

@ -13,14 +13,14 @@ import ollama from 'ollama'
// Promisify exec for using async/await // Promisify exec for using async/await
const execPromise = promisify(exec); const execPromise = promisify(exec);
const modelfilePath = "/Volumes/AGI/agi-mf"
const systemSavePath = "/Volumes/AGI/agi-save" const systemSavePath = "/Volumes/AGI/agi-save"
const modelID = "local-agsamantha" const modelID = "local-agsamantha"
const maxDepthCount = 11 const maxDepthCount = 11
let ags_modelfile;
function ask(q) { function ask(q) {
return new Promise((resolve) => { return new Promise((resolve) => {
const rl = readline.createInterface({ const rl = readline.createInterface({
@ -37,14 +37,7 @@ function ask(q) {
// Function to run the publishing commands // Function to run the publishing commands
async function runPublishCommands() { async function runPublishCommands() {
try { try {
// Execute the 'ollama create' command ollama.create({ model: 'example', modelfile: ags_modelfile })
const createCommand = `ollama create ${modelID} -f ${modelfilePath}`;
//console.log(`Running command: ${createCommand}`);
const { stdout: createStdout, stderr: createStderr } = await execPromise(createCommand);
//console.log('Create Command Output:', createStdout);
if (createStderr) {
console.error('Create Command Error:', createStderr);
}
// Execute the 'ollama push' command // Execute the 'ollama push' command
//const pushCommand = `killall ollama && ollama push ${modelID}`; //const pushCommand = `killall ollama && ollama push ${modelID}`;
@ -182,7 +175,6 @@ let userAGIInput = `
`; `;
async function generateModelfile(c) { async function generateModelfile(c) {
let ags_modelfile;
try { try {
ags_modelfile = await readFile(systemSavePath, { encoding: 'utf8' }) || ags_template_part1; ags_modelfile = await readFile(systemSavePath, { encoding: 'utf8' }) || ags_template_part1;
} catch (err) { } catch (err) {
@ -196,16 +188,10 @@ async function generateModelfile(c) {
} }
ags_modelfile += createUserContextPart(userAGIInput); ags_modelfile += createUserContextPart(userAGIInput);
await writeFile(systemSavePath, ags_modelfile) await writeFile(systemSavePath, ags_modelfile)
.then(() => {})
.catch(err => { .catch(err => {
console.error('Error writing file:', err); console.error('Error writing file:', err);
}); });
ags_modelfile += ags_template_finalpart; ags_modelfile += ags_template_finalpart;
await writeFile(modelfilePath, ags_modelfile)
.then(() => {})
.catch(err => {
console.error('Error writing file:', err);
});
return ags_modelfile; return ags_modelfile;
} }
@ -235,13 +221,13 @@ async function learningLoop() {
async function talkLoop() { async function talkLoop() {
while (true) { while (true) {
let q = await ask(`To ${modelID}: `); let q = await ask(`To ${modelID}: `);
userAGIInput += ` userAGIInput += await `
USER: ${q}`; USER: ${q}`;
let a = await ollama.chat({ let a = await ollama.chat({
model: `${modelID}`, model: `${modelID}`,
messages: [{ role: 'user', content: `${q}` }], messages: [{ role: 'user', content: `${q}` }],
}); });
userAGIInput += ` userAGIInput += await `
AI: ${a.message.content}`; AI: ${a.message.content}`;
console.log(`${a.message.content}`); console.log(`${a.message.content}`);