@nine-lab/nine-mu 0.1.178 → 0.1.180
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/dist/nine-mu.js +508 -490
- package/dist/nine-mu.js.map +1 -1
- package/dist/nine-mu.umd.js +3 -3
- package/dist/nine-mu.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/NineChat.js +6 -5
- package/src/components/NineChatManager.js +27 -3
package/package.json
CHANGED
|
@@ -84,22 +84,23 @@ export class NineChat extends HTMLElement {
|
|
|
84
84
|
this.#$nineChatMessage.add("me", userInput);
|
|
85
85
|
this.#$nineChatMessage.add("ing", ""); // 로딩 상태
|
|
86
86
|
|
|
87
|
+
// 3. nine.safe로 매니저 로직 실행
|
|
88
|
+
const [result, err] = await nine.safe(this.#manager.handleChatSubmit(target.value));
|
|
89
|
+
|
|
87
90
|
// 2. 입력창 비우기
|
|
88
91
|
setTimeout(() => {
|
|
89
92
|
target.value = "";
|
|
90
93
|
});
|
|
91
94
|
|
|
92
|
-
// 3. nine.safe로 매니저 로직 실행
|
|
93
|
-
const [result, err] = await nine.safe(this.#manager.handleChatSubmit(target));
|
|
94
|
-
|
|
95
95
|
target.removeAttribute('disabled');
|
|
96
96
|
target.focus();
|
|
97
97
|
|
|
98
98
|
if (err) {
|
|
99
|
-
|
|
99
|
+
trace.error(err);
|
|
100
100
|
this.#$nineChatMessage.add("ai", err.message || "알 수 없는 오류가 발생했습니다. 다시 시도해주세요.");
|
|
101
101
|
} else {
|
|
102
|
-
|
|
102
|
+
trace.log(result);
|
|
103
|
+
this.#manager.addChatHistory(result.message);
|
|
103
104
|
this.#$nineChatMessage.add("ai", result.message);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
@@ -139,14 +139,38 @@ export class NineChatManager {
|
|
|
139
139
|
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
handleChatSubmit = async
|
|
142
|
+
handleChatSubmit = async v => {
|
|
143
143
|
|
|
144
144
|
const routes = await this.#getRoutes();
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
return await this.#callTool("system-brain", {
|
|
147
|
+
user_input : v,
|
|
148
|
+
routes : routes,
|
|
149
|
+
current_path : "/group_member/student_management",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
#chatHistory = []; // 💡 이전 대화들을 저장할 메모리 창고
|
|
154
|
+
|
|
155
|
+
addChatHistory(message) {
|
|
156
|
+
|
|
157
|
+
this.#chatHistory.push({ role: 'ai', text: result.message });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
handleChatSubmit = async v => {
|
|
161
|
+
|
|
162
|
+
this.#chatHistory.push({ role: 'user', text: v });
|
|
163
|
+
|
|
164
|
+
// 1. 이전 대화 내역을 하나의 텍스트 포맷으로 예쁘게 말아줍니다.
|
|
165
|
+
const formattedHistory = this.#chatHistory.map(chat => {
|
|
166
|
+
return chat.role === 'user' ? `User: ${chat.text}` : `AI: ${chat.text}`;
|
|
167
|
+
}).join('\n');
|
|
168
|
+
|
|
147
169
|
|
|
170
|
+
// 2. AI 호출 시 history를 함께 실어서 보냅니다.
|
|
148
171
|
return await this.#callTool("system-brain", {
|
|
149
|
-
user_input :
|
|
172
|
+
user_input : v,
|
|
173
|
+
chat_history: formattedHistory,
|
|
150
174
|
routes : routes,
|
|
151
175
|
current_path : "/group_member/student_management",
|
|
152
176
|
});
|