shivam-cli-generator 1.0.9 → 1.1.1
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 +10 -35
- package/package.json +1 -1
package/ai.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Version 1.0.5
|
|
1
2
|
import dotenv from 'dotenv';
|
|
2
3
|
import { fileURLToPath } from 'url';
|
|
3
4
|
import { dirname, join } from 'path';
|
|
@@ -6,41 +7,19 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
6
7
|
const __dirname = dirname(__filename);
|
|
7
8
|
|
|
8
9
|
// Load .env from the package directory, not the current working directory
|
|
9
|
-
|
|
10
|
-
const result = dotenv.config({ path: envPath, override: true });
|
|
11
|
-
|
|
12
|
-
if (result.error) {
|
|
13
|
-
console.error("⚠️ Error loading .env from:", envPath, result.error);
|
|
14
|
-
} else {
|
|
15
|
-
// console.log("✅ Loaded .env from:", envPath);
|
|
16
|
-
// console.log("✅ Loaded .env from:", envPath);
|
|
17
|
-
}
|
|
10
|
+
dotenv.config({ path: join(__dirname, '.env') });
|
|
18
11
|
import Groq from "groq-sdk";
|
|
19
|
-
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
20
12
|
import fs from "fs";
|
|
21
13
|
import readline from "readline-sync";
|
|
22
|
-
const apiKey = process.env.GROQ_API_KEY
|
|
23
|
-
|
|
24
|
-
// if (!apiKey) {
|
|
25
|
-
// console.error("❌ GROQ_API_KEY is missing.\n👉 Please check your .env file or system environment variables.\n");
|
|
26
|
-
// process.exit(1);
|
|
27
|
-
// }
|
|
14
|
+
const apiKey = process.env.GROQ_API_KEY;
|
|
28
15
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (proxyUrl) {
|
|
34
|
-
console.log(`Using Proxy: ${proxyUrl}`);
|
|
35
|
-
httpAgent = new HttpsProxyAgent(proxyUrl);
|
|
16
|
+
if (!apiKey) {
|
|
17
|
+
console.error("❌ GROQ_API_KEY is missing.\n👉 Please check your .env file or system environment variables.\n");
|
|
18
|
+
process.exit(1);
|
|
36
19
|
}
|
|
37
20
|
|
|
38
21
|
// ✅ Correct Groq client initialization
|
|
39
|
-
const client = new Groq({
|
|
40
|
-
apiKey: apiKey.trim(),
|
|
41
|
-
httpAgent: httpAgent,
|
|
42
|
-
baseURL: process.env.GROQ_BASE_URL // Allow custom base URL (e.g. for relays)
|
|
43
|
-
});
|
|
22
|
+
const client = new Groq({ apiKey });
|
|
44
23
|
|
|
45
24
|
// ✅ Use the inputURL if provided
|
|
46
25
|
const inputURL = process.argv[2];
|
|
@@ -95,13 +74,9 @@ async function main() {
|
|
|
95
74
|
}
|
|
96
75
|
|
|
97
76
|
} catch (error) {
|
|
98
|
-
|
|
99
|
-
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND'
|
|
100
|
-
console.error("
|
|
101
|
-
console.error("👉 CAUSE: Your network (Office WiFi/Firewall) is likely blocking access to AI services.");
|
|
102
|
-
console.error("💡 SOLUTION: Please use a **VPN** (as you found works) or a personal hotspot.");
|
|
103
|
-
} else {
|
|
104
|
-
console.error("\n❌ Error communicating with AI:", error.message);
|
|
77
|
+
console.error("\n❌ Error communicating with AI:", error.message);
|
|
78
|
+
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND') {
|
|
79
|
+
console.error("👉 Check your internet connection.\n");
|
|
105
80
|
}
|
|
106
81
|
}
|
|
107
82
|
}
|