shivam-cli-generator 1.0.6 → 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/ai.js +22 -4
- package/package.json +2 -1
package/ai.js
CHANGED
|
@@ -13,8 +13,10 @@ if (result.error) {
|
|
|
13
13
|
console.error("⚠️ Error loading .env from:", envPath, result.error);
|
|
14
14
|
} else {
|
|
15
15
|
// console.log("✅ Loaded .env from:", envPath);
|
|
16
|
+
// console.log("✅ Loaded .env from:", envPath);
|
|
16
17
|
}
|
|
17
18
|
import Groq from "groq-sdk";
|
|
19
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
18
20
|
import fs from "fs";
|
|
19
21
|
import readline from "readline-sync";
|
|
20
22
|
const apiKey = process.env.GROQ_API_KEY || "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";
|
|
@@ -24,8 +26,20 @@ const apiKey = process.env.GROQ_API_KEY || "gsk_Sx0lwIbaZlHpYJrcQDLFWGdyb3FYqExM
|
|
|
24
26
|
// process.exit(1);
|
|
25
27
|
// }
|
|
26
28
|
|
|
29
|
+
// ✅ Proxy Configuration
|
|
30
|
+
const proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
|
|
31
|
+
let httpAgent = undefined;
|
|
32
|
+
|
|
33
|
+
if (proxyUrl) {
|
|
34
|
+
console.log(`Using Proxy: ${proxyUrl}`);
|
|
35
|
+
httpAgent = new HttpsProxyAgent(proxyUrl);
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
// ✅ Correct Groq client initialization
|
|
28
|
-
const client = new Groq({
|
|
39
|
+
const client = new Groq({
|
|
40
|
+
apiKey: apiKey.trim(),
|
|
41
|
+
httpAgent: httpAgent
|
|
42
|
+
});
|
|
29
43
|
|
|
30
44
|
// ✅ Use the inputURL if provided
|
|
31
45
|
const inputURL = process.argv[2];
|
|
@@ -80,9 +94,13 @@ async function main() {
|
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
} catch (error) {
|
|
83
|
-
console.error("\n❌ Error communicating with AI:", error.message);
|
|
84
|
-
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND') {
|
|
85
|
-
console.error("
|
|
97
|
+
// console.error("\n❌ Error communicating with AI:", error.message);
|
|
98
|
+
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND' || error.message.includes('Connection error') || error.message.includes('fetch failed')) {
|
|
99
|
+
console.error("\n❌ NETWORK ERROR: Unable to connect to Groq API.");
|
|
100
|
+
console.error("👉 CAUSE: Your network (Office WiFi/Firewall) is likely blocking access to AI services.");
|
|
101
|
+
console.error("💡 SOLUTION: Please use a **VPN** (as you found works) or a personal hotspot.");
|
|
102
|
+
} else {
|
|
103
|
+
console.error("\n❌ Error communicating with AI:", error.message);
|
|
86
104
|
}
|
|
87
105
|
}
|
|
88
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shivam-cli-generator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "ai.js",
|
|
6
6
|
"type": "module",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"dotenv": "^17.2.3",
|
|
18
18
|
"groq-sdk": "^0.37.0",
|
|
19
|
+
"https-proxy-agent": "^7.0.6",
|
|
19
20
|
"readline-sync": "^1.4.10"
|
|
20
21
|
}
|
|
21
22
|
}
|