abhinav24 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +48 -0
- package/package.json +24 -0
package/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import Groq from "groq-sdk";
|
|
3
|
+
import readline from "readline";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
|
|
6
|
+
const groq = new Groq({
|
|
7
|
+
apiKey: "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"
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const rl = readline.createInterface({
|
|
11
|
+
input: process.stdin,
|
|
12
|
+
output: process.stdout
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
async function askBot(message) {
|
|
18
|
+
const chat = await groq.chat.completions.create({
|
|
19
|
+
model: "meta-llama/llama-4-maverick-17b-128e-instruct",
|
|
20
|
+
messages: [
|
|
21
|
+
{ role: "system", content: "You are a helpful AI assistant." },
|
|
22
|
+
{ role: "user", content: message }
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return chat.choices[0].message.content;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
function chat() {
|
|
31
|
+
rl.question("You: ", async (msg) => {
|
|
32
|
+
if (msg.toLowerCase() === "exit") {
|
|
33
|
+
rl.close();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const reply = await askBot(msg);
|
|
39
|
+
console.log("Re:", reply);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.log(chalk.red("Error:"), e.message);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
chat();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
chat();
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "abhinav24",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Terminal AI Chatbot using LLaMA 3",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"chatbot": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"ai",
|
|
12
|
+
"chatbot",
|
|
13
|
+
"terminal",
|
|
14
|
+
"llama",
|
|
15
|
+
"groq"
|
|
16
|
+
],
|
|
17
|
+
"author": "Your Name",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"groq-sdk": "^0.5.0",
|
|
21
|
+
"readline": "^1.3.0",
|
|
22
|
+
"chalk": "^5.3.0"
|
|
23
|
+
}
|
|
24
|
+
}
|