@nine-lab/nine-mu 0.1.179 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nine-lab/nine-mu",
3
- "version": "0.1.179",
3
+ "version": "0.1.180",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -100,6 +100,7 @@ export class NineChat extends HTMLElement {
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
  }
@@ -149,4 +149,30 @@ export class NineChatManager {
149
149
  current_path : "/group_member/student_management",
150
150
  });
151
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
+
169
+
170
+ // 2. AI 호출 시 history를 함께 실어서 보냅니다.
171
+ return await this.#callTool("system-brain", {
172
+ user_input : v,
173
+ chat_history: formattedHistory,
174
+ routes : routes,
175
+ current_path : "/group_member/student_management",
176
+ });
177
+ }
152
178
  }