@devangkumar/dvai 1.0.3 → 1.0.5
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 +1 -1
- package/src/index.js +17 -15
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GoogleGenerativeAI } from "@google/generative-ai";
|
|
2
|
-
import { Command } from "commander";
|
|
3
2
|
import ora from "ora";
|
|
4
3
|
import inquirer from "inquirer";
|
|
5
4
|
|
|
@@ -8,8 +7,6 @@ const HARDCODED_API_KEY = "AIzaSyDkVgrWXHa7oyPasZGqNOZ-OyA-uYIDtXc";
|
|
|
8
7
|
const genAI = new GoogleGenerativeAI(HARDCODED_API_KEY);
|
|
9
8
|
const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash" });
|
|
10
9
|
|
|
11
|
-
const program = new Command();
|
|
12
|
-
|
|
13
10
|
async function startChat(initialHistory = []) {
|
|
14
11
|
let chatHistory = initialHistory;
|
|
15
12
|
while (true) {
|
|
@@ -38,18 +35,23 @@ async function startChat(initialHistory = []) {
|
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
async function run() {
|
|
39
|
+
const args = process.argv.slice(2);
|
|
40
|
+
|
|
41
|
+
// If no arguments, start chat immediately
|
|
42
|
+
if (args.length === 0) {
|
|
43
|
+
await startChat();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// If "chat" command is used
|
|
48
|
+
if (args[0] === "chat") {
|
|
49
|
+
await startChat();
|
|
50
|
+
return;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
// Otherwise,
|
|
53
|
+
// Otherwise, treat arguments as a single prompt
|
|
54
|
+
const prompt = args.join(" ");
|
|
53
55
|
const spinner = ora({ text: "", isSilent: true }).start();
|
|
54
56
|
try {
|
|
55
57
|
const result = await model.generateContent(prompt);
|
|
@@ -59,6 +61,6 @@ program
|
|
|
59
61
|
spinner.stop();
|
|
60
62
|
console.error("Error:", error.message);
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
}
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
run();
|