commit b3cd0b620ca792ec8300eafc1e5fa9bf256952f8 Author: Sneed Group Holder Date: Sun Nov 3 15:46:07 2024 -0600 first diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5766c11 --- /dev/null +++ b/index.mjs @@ -0,0 +1,44 @@ +import { Ollama } from 'ollama' +import { createInterface } from 'readline'; + +const model = "sparksammy/thinking-eggplant" +const hostURL = "https://ollama-api.nodemixaholic.com" + +const ollama = new Ollama({ host: hostURL }) + +async function getResponse(q) { + const response = await ollama.chat({ + model: model, + messages: [{ role: 'user', content: String(`${q}`) }], + }) + return response.message.content; +} + +const rl = createInterface({ + input: process.stdin, + output: process.stdout +}); + +const askQuestion = () => { + return new Promise((resolve) => { + rl.question('S:> ', (a) => { + resolve(a); + }); + }); +}; + + +async function main() { +while (true) { + const a = await askQuestion(); + if (a.toLowerCase() == "goodbye" || a.toLowerCase() == "bye" || a.toLowerCase() == "quit" || a.toLowerCase() == "exit") { + console.log("So long!") + rl.close(); // close the readline interface + break; // exit loop + } else { + const response = await getResponse(a) + console.log(response) + } + } +} +main() diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..6774faf --- /dev/null +++ b/package-lock.json @@ -0,0 +1,30 @@ +{ + "name": "samantha-webui", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "samantha-webui", + "version": "1.0.0", + "dependencies": { + "ollama": "^0.5.9" + } + }, + "node_modules/ollama": { + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/ollama/-/ollama-0.5.9.tgz", + "integrity": "sha512-F/KZuDRC+ZsVCuMvcOYuQ6zj42/idzCkkuknGyyGVmNStMZ/sU3jQpvhnl4SyC0+zBzLiKNZJnJeuPFuieWZvQ==", + "license": "MIT", + "dependencies": { + "whatwg-fetch": "^3.6.20" + } + }, + "node_modules/whatwg-fetch": { + "version": "3.6.20", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz", + "integrity": "sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==", + "license": "MIT" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..cb8d5b0 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "samantha-cli", + "version": "1.0.0", + "main": "index.mjs", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "", + "description": "", + "dependencies": { + "ollama": "^0.5.9" + } +}