@devangkumar/dvai 1.0.7 → 1.0.8
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/package.json +2 -1
- package/src/index.js +23 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devangkumar/dvai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A powerful AI assistant for your terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"chalk": "^5.6.2",
|
|
24
24
|
"commander": "^14.0.3",
|
|
25
25
|
"devang-super-ai-terminal-v1": "^1.0.0",
|
|
26
|
+
"groq-sdk": "^1.2.0",
|
|
26
27
|
"inquirer": "^8.2.4",
|
|
27
28
|
"ora": "^5.4.1"
|
|
28
29
|
}
|
package/src/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Groq from "groq-sdk";
|
|
2
2
|
import ora from "ora";
|
|
3
3
|
import inquirer from "inquirer";
|
|
4
4
|
|
|
5
5
|
// --- CONFIGURATION ---
|
|
6
|
-
//
|
|
7
|
-
const _k = "
|
|
6
|
+
// Replace this with your encoded Groq API Key
|
|
7
|
+
const _k = "Z3NrX0pnUTkyZjdqUWVSYzRKdUtLQkt6V0dyeWIzRll3UmF0bDNkNDM4S21zZ0VGdFJscDIydmc=";
|
|
8
8
|
const HARDCODED_API_KEY = Buffer.from(_k, 'base64').toString();
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const groq = new Groq({ apiKey: HARDCODED_API_KEY });
|
|
11
|
+
const MODEL = "llama-3.1-70b-versatile";
|
|
12
12
|
|
|
13
13
|
async function startChat(initialHistory = []) {
|
|
14
14
|
let chatHistory = initialHistory;
|
|
@@ -24,13 +24,20 @@ async function startChat(initialHistory = []) {
|
|
|
24
24
|
|
|
25
25
|
const spinner = ora({ text: "", isSilent: true }).start();
|
|
26
26
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const response = await groq.chat.completions.create({
|
|
28
|
+
messages: [
|
|
29
|
+
...chatHistory,
|
|
30
|
+
{ role: "user", content: userInput }
|
|
31
|
+
],
|
|
32
|
+
model: MODEL,
|
|
33
|
+
});
|
|
34
|
+
|
|
29
35
|
spinner.stop();
|
|
30
|
-
const
|
|
31
|
-
process.stdout.write(
|
|
32
|
-
|
|
33
|
-
chatHistory.push({ role: "
|
|
36
|
+
const reply = response.choices[0]?.message?.content || "";
|
|
37
|
+
process.stdout.write(reply + "\n\n");
|
|
38
|
+
|
|
39
|
+
chatHistory.push({ role: "user", content: userInput });
|
|
40
|
+
chatHistory.push({ role: "assistant", content: reply });
|
|
34
41
|
} catch (error) {
|
|
35
42
|
spinner.stop();
|
|
36
43
|
console.error("Error:", error.message);
|
|
@@ -49,9 +56,12 @@ async function run() {
|
|
|
49
56
|
const prompt = args.join(" ");
|
|
50
57
|
const spinner = ora({ text: "", isSilent: true }).start();
|
|
51
58
|
try {
|
|
52
|
-
const
|
|
59
|
+
const response = await groq.chat.completions.create({
|
|
60
|
+
messages: [{ role: "user", content: prompt }],
|
|
61
|
+
model: MODEL,
|
|
62
|
+
});
|
|
53
63
|
spinner.stop();
|
|
54
|
-
process.stdout.write(
|
|
64
|
+
process.stdout.write(response.choices[0]?.message?.content + "\n");
|
|
55
65
|
} catch (error) {
|
|
56
66
|
spinner.stop();
|
|
57
67
|
console.error("Error:", error.message);
|