shivam-cli-generator 1.0.2 → 1.0.3
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/ai.js +12 -6
- package/package.json +1 -1
package/ai.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import Groq from "groq-sdk";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import readline from "readline-sync";
|
|
4
|
-
import dotenv from "dotenv";
|
|
5
|
-
dotenv.config({ override: false });
|
|
6
4
|
|
|
5
|
+
// ✅ Get API Key from system environment only
|
|
6
|
+
const apiKey = process.env.GROQ_API_KEY;
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
if (!apiKey) {
|
|
9
|
+
console.error("❌ GROQ_API_KEY is missing.\n👉 Set it using:\n\nsetx GROQ_API_KEY \"your_groq_api_key_here\"\n");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// ✅ Correct Groq client initialization
|
|
14
|
+
const client = new Groq({ apiKey });
|
|
9
15
|
|
|
10
16
|
const inputURL = process.argv[2] || readline.question("Enter URL: ");
|
|
11
17
|
|
|
@@ -21,14 +27,14 @@ async function main() {
|
|
|
21
27
|
console.log("⏳ Generating...");
|
|
22
28
|
|
|
23
29
|
const response = await client.chat.completions.create({
|
|
24
|
-
model: "llama-3.1-8b-instant",
|
|
30
|
+
model: "llama-3.1-8b-instant",
|
|
25
31
|
messages: [
|
|
26
|
-
{ role: "system", content: "You generate clean code.
|
|
32
|
+
{ role: "system", content: "You generate clean code. Only code or required output." },
|
|
27
33
|
{ role: "user", content: question }
|
|
28
34
|
]
|
|
29
35
|
});
|
|
30
36
|
|
|
31
|
-
const output = response.choices[0].message.content;
|
|
37
|
+
const output = response.choices[0].message.content.trim();
|
|
32
38
|
|
|
33
39
|
if (!fs.existsSync("generated")) fs.mkdirSync("generated");
|
|
34
40
|
|