aifee 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/aifee.js +60 -0
- package/package.json +15 -0
package/aifee.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const axios = require("axios");
|
|
4
|
+
const readline = require("readline");
|
|
5
|
+
|
|
6
|
+
const API_KEY = "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";
|
|
7
|
+
|
|
8
|
+
const rl = readline.createInterface({
|
|
9
|
+
input: process.stdin,
|
|
10
|
+
output: process.stdout
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
console.log("AI Started");
|
|
14
|
+
console.log("Type 'exit' to quit\n");
|
|
15
|
+
|
|
16
|
+
function chat() {
|
|
17
|
+
rl.question("You: ", async (question) => {
|
|
18
|
+
|
|
19
|
+
if (question.toLowerCase() === "exit") {
|
|
20
|
+
rl.close();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
|
|
26
|
+
const response = await axios.post(
|
|
27
|
+
"https://api.groq.com/openai/v1/chat/completions",
|
|
28
|
+
{
|
|
29
|
+
model: "llama-3.3-70b-versatile",
|
|
30
|
+
messages: [
|
|
31
|
+
{
|
|
32
|
+
role: "user",
|
|
33
|
+
content: question
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
40
|
+
"Content-Type": "application/json"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
console.log(
|
|
46
|
+
"\nAI:",
|
|
47
|
+
response.data.choices[0].message.content,
|
|
48
|
+
"\n"
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.log(err.message);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
chat();
|
|
56
|
+
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
chat();
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aifee",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"description": "",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"axios": "^1.16.1"
|
|
14
|
+
}
|
|
15
|
+
}
|