shivam-cli-generator 1.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/.env +5 -0
- package/ai.js +42 -0
- package/cli.js +3 -0
- package/package.json +24 -0
package/.env
ADDED
package/ai.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Groq from "groq-sdk";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import readline from "readline-sync";
|
|
4
|
+
import dotenv from "dotenv";
|
|
5
|
+
|
|
6
|
+
dotenv.config();
|
|
7
|
+
|
|
8
|
+
const client = new Groq({ apiKey: process.env.GROQ_API_KEY });
|
|
9
|
+
|
|
10
|
+
const inputURL = process.argv[2] || readline.question("Enter URL: ");
|
|
11
|
+
|
|
12
|
+
console.log("\nš URL received:", inputURL);
|
|
13
|
+
console.log("š” Ask anything to AI. Type 'exit' to quit.\n");
|
|
14
|
+
|
|
15
|
+
async function main() {
|
|
16
|
+
while (true) {
|
|
17
|
+
const question = readline.question("AI > ");
|
|
18
|
+
|
|
19
|
+
if (question.toLowerCase() === "exit") break;
|
|
20
|
+
|
|
21
|
+
console.log("ā³ Generating...");
|
|
22
|
+
|
|
23
|
+
const response = await client.chat.completions.create({
|
|
24
|
+
model: "llama-3.1-8b-instant", // ā
NEW WORKING MODEL
|
|
25
|
+
messages: [
|
|
26
|
+
{ role: "system", content: "You generate clean code. No extra text." },
|
|
27
|
+
{ role: "user", content: question }
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const output = response.choices[0].message.content;
|
|
32
|
+
|
|
33
|
+
if (!fs.existsSync("generated")) fs.mkdirSync("generated");
|
|
34
|
+
|
|
35
|
+
const fileName = `generated/output_${Date.now()}.txt`;
|
|
36
|
+
fs.writeFileSync(fileName, output);
|
|
37
|
+
|
|
38
|
+
console.log(`\nā
File generated: ${fileName}\n`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
main();
|
package/cli.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "shivam-cli-generator",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "ai.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"shivam-ai": "./cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node ai.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"dotenv": "^17.2.3",
|
|
18
|
+
"groq-sdk": "^0.37.0",
|
|
19
|
+
"openai": "^6.16.0",
|
|
20
|
+
"readline-sync": "^1.4.10"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
}
|