flame-ai 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/README.md +82 -0
- package/index.js +90 -0
- package/package.json +12 -0
- package/test.js +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# FlameAI Module
|
|
2
|
+
|
|
3
|
+
## ๐ ์์ํ๊ธฐ
|
|
4
|
+
|
|
5
|
+
### ์ค์น
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install flame-ai
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## ๐ ๏ธ ์ฌ์ฉ๋ฒ
|
|
12
|
+
|
|
13
|
+
### 1. ๋ชจ๋ ๋ถ๋ฌ์ค๊ธฐ
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
const flameAI = require("flame-ai");
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 2. ์ฑํ
์ธ์
์์ฑ (`createChat`)
|
|
20
|
+
|
|
21
|
+
์๋ก์ด AI ๋ํ ์ธ์
์ ์์ฑํฉ๋๋ค. AI์ ์ญํ ๊ณผ ์ ์ ์ ํ๋ฅด์๋๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค.
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
const prompt = {
|
|
25
|
+
bot_role: "๋๋ ์น์ ํ ๊ณ ์์ด ์ฝ๋ฉ ๋์ฐ๋ฏธ์ผ. ๋ง ๋๋ง๋ค '๋ฅ'์ ๋ถ์ฌ์ค.",
|
|
26
|
+
user_role: "ํ์"
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const chatInfo = await flameAI.createChat(prompt);
|
|
31
|
+
console.log("์์ฑ๋ ์ธ์
ID:", chatInfo.chatId);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("์ธ์
์์ฑ ์คํจ:", error.message);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 3. ๋ฉ์์ง ์ ์ก (`sendMessage`)
|
|
38
|
+
|
|
39
|
+
์์ฑ๋ `chatId`๋ฅผ ์ฌ์ฉํ์ฌ AI์ ๋ํ๋ฅผ ์ฃผ๊ณ ๋ฐ์ต๋๋ค.
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
const chatId = "์์ฑ๋ฐ์_chatID"; // createChat์์ ๋ฐํ๋ chatId
|
|
43
|
+
const data = {
|
|
44
|
+
message: "์๋
! ์ค๋ ๊ฐ๋ฐํ๊ธฐ ์ข์ ๋ ์จ๋ค."
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const result = await flameAI.sendMessage(chatId, data);
|
|
49
|
+
console.log("AI ์๋ต:", result.response);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("๋ฉ์์ง ์ ์ก ์คํจ:", error.message);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## ๐ API ๋ช
์ธ
|
|
56
|
+
|
|
57
|
+
### `createChat(prompt)`
|
|
58
|
+
- **์ธ์**: `prompt` (Object)
|
|
59
|
+
- `bot_role`: AI์ ์ญํ ์ค์ (ํ์)
|
|
60
|
+
- `user_role`: ์ ์ ์ ์ญํ ์ค์ (ํ์)
|
|
61
|
+
- **๋ฐํ**: `Promise<Object>`
|
|
62
|
+
```javascript
|
|
63
|
+
{
|
|
64
|
+
chatId: "string", // ์ธ์
๊ณ ์ ID
|
|
65
|
+
prompt: { bot_role, user_role }
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### `sendMessage(chatId, data)`
|
|
70
|
+
- **์ธ์**:
|
|
71
|
+
- `chatId`: `createChat`์์ ์์ฑ๋ ID (String)
|
|
72
|
+
- `data`: `{ message: "๋ด์ฉ" }` (Object)
|
|
73
|
+
- **๋ฐํ**: `Promise<Object>`
|
|
74
|
+
```javascript
|
|
75
|
+
{
|
|
76
|
+
chatId: "string",
|
|
77
|
+
question: "์ ์ ๊ฐ ๋ณด๋ธ ์ง๋ฌธ",
|
|
78
|
+
response: "AI์ ๋ต๋ณ"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
---
|
|
82
|
+
โ Flame. 2026. All rights reserved.
|
package/index.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// โโโ โโโโโโโ โโโโ
|
|
2
|
+
// โโโโ โโโโโโโ โโโโ โโ
|
|
3
|
+
// โโโโโโ โโโโ โโโโ โโโ โโโ
|
|
4
|
+
// โโโโโโโโ โโโ โโโโโโโโโโโ โโโโ โโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโ โโโโโ
|
|
5
|
+
// โโโโโโโโ โโโโโ โโโโโโโโโโโ โโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโ โโ
|
|
6
|
+
// โโโโโโโโโโโโโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโ โโโ โโ
|
|
7
|
+
// โโโโโโโโโโโโโโโโโ โโโโ โโโโ โโโโโโโโโโโโโ โโโโ โโโโ โโโโ โโโโโโโโโโโโโโ โโ โโ โโ
|
|
8
|
+
// โโโโโโโ โโโโโโโโโ โโโโ โโโโ โโโโโโโโโโโโโโ โโโโ โโโโ โโโโ โโโโโโโโโโโโโ โโโโโโโโโโโ โโ
|
|
9
|
+
// โโโโโ โโโโโโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโโโ โโ โโ โโ
|
|
10
|
+
// โโโโ โโโโโโ โโโโ โโโโ โโโโโโโโโโโโโโ โโโโ โโโโ โโโโ โโโโโโโ โโโ โโ โโ โโ
|
|
11
|
+
// โโ โโโโ โโโโ โโโโ โโโโโโโโโโโโ โโโโ โโโโ โโโโ โโโโโโโโโโโโโ โโ โโ โโ
|
|
12
|
+
|
|
13
|
+
// ํํ, ์ด๊ณณ๊น์ง ์ค์ค ์ค ์๊ณ ์ค์ํ ์ฝ๋๋ ๋ฐฑ์๋๋ก ์ฎ๊ฒจ๋จ์ต๋๋ค.
|
|
14
|
+
// ํน์ ์ค๋ฅ ๋ฐ์์ด๋ ์คํ์ด ์๋์๋์? [ํผ๋๋ฐฑ ๋์ค์ฝ๋ ์๋ฒ -> https://discord.gg/NTZj5Xuq3S]
|
|
15
|
+
// ์ฌ์ฉ๋ฒ์ด๋ ์ฐธ๊ณ ๋ README.md๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.
|
|
16
|
+
// โ Flame. 2026. All rights reserved.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const axios = require("axios");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* FlameAI Module
|
|
23
|
+
* baseURL: https://flameai.jeeks.me/api
|
|
24
|
+
*/
|
|
25
|
+
const baseURL = "https://flameai.jeeks.me/api";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ์๋ก์ด ์ฑํ
์ธ์
์ ์์ฑํฉ๋๋ค.
|
|
29
|
+
* @param {Object} prompt { bot_role, user_role }
|
|
30
|
+
* @returns {Promise<Object>} { chatId, prompt }
|
|
31
|
+
*/
|
|
32
|
+
async function createChat(prompt) {
|
|
33
|
+
if (!prompt || !prompt.bot_role || !prompt.user_role) {
|
|
34
|
+
throw new Error("prompt ๊ฐ์ฒด์ bot_role๊ณผ user_role์ด ํฌํจ๋์ด์ผ ํฉ๋๋ค.");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const response = await axios.post(`${baseURL}/create`, { prompt });
|
|
39
|
+
|
|
40
|
+
if (response.data?.error) {
|
|
41
|
+
throw new Error(`Flame ์๋ฒ ์ค๋ฅ: ${response.data.error}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return response.data.data;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error.response) {
|
|
47
|
+
throw new Error(`์๋ฒ ์๋ต ์ค๋ฅ (${error.response.status}): ${JSON.stringify(error.response.data)}`);
|
|
48
|
+
}
|
|
49
|
+
throw error.message || "์ค๋ฅ๊ฐ ๋ฐ์ํ์์ต๋๋ค.";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* ๋ฉ์์ง๋ฅผ ์ ์กํฉ๋๋ค.
|
|
55
|
+
* @param {string} chatId ์ธ์
ID
|
|
56
|
+
* @param {Object} data { message }
|
|
57
|
+
* @returns {Promise<Object>} { chatId, question, response }
|
|
58
|
+
*/
|
|
59
|
+
async function sendMessage(chatId, data) {
|
|
60
|
+
if (!chatId || !data || !data.message) {
|
|
61
|
+
throw new Error("chatId์ message๊ฐ ํ์ํฉ๋๋ค.");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const response = await axios.post(`${baseURL}/chat`, {
|
|
66
|
+
chatId,
|
|
67
|
+
message: data.message
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (response.data?.error) {
|
|
71
|
+
throw new Error(`Flame ์๋ฒ ์ค๋ฅ: ${response.data.error}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
chatId: chatId,
|
|
76
|
+
question: data.message,
|
|
77
|
+
response: response.data.data
|
|
78
|
+
};
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (error.response) {
|
|
81
|
+
throw new Error(`์๋ฒ ์๋ต ์ค๋ฅ (${error.response.status}): ${JSON.stringify(error.response.data)}`);
|
|
82
|
+
}
|
|
83
|
+
throw error.message || "์ค๋ฅ๊ฐ ๋ฐ์ํ์์ต๋๋ค.\n๋๋ ์ ํจํ์ง ์๋ chatId์
๋๋ค.";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
createChat,
|
|
89
|
+
sendMessage
|
|
90
|
+
};
|
package/package.json
ADDED
package/test.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const flameAI = require("./index");
|
|
2
|
+
|
|
3
|
+
(async () => {
|
|
4
|
+
try {
|
|
5
|
+
const chatInfo = await flameAI.createChat({
|
|
6
|
+
bot_role: "๋๋ ์ฒ ํ๊ฐ์ผ. ๋ง ๋๋ง๋ค ์ด๋ค์์ ๋ถ์ฌ.",
|
|
7
|
+
user_role: "์ด๋ฆ: ์ง๊ด"
|
|
8
|
+
});
|
|
9
|
+
console.log("Chat Created:", chatInfo);
|
|
10
|
+
|
|
11
|
+
const response = await flameAI.sendMessage(chatInfo.chatId, {
|
|
12
|
+
message: "์ธ์์ด๋ ๋ฌด์์ธ๊ฐ."
|
|
13
|
+
});
|
|
14
|
+
console.log("Bot Response:", response);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("Error:", error);
|
|
17
|
+
}
|
|
18
|
+
})();
|