natureco-cli 2.4.2 → 2.4.4
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 +1 -1
- package/src/commands/chat.js +4 -1
- package/src/commands/dashboard.js +2 -2
- package/src/commands/gateway-server.js +1 -1
- package/src/utils/api.js +1 -1
- package/src/utils/memory.js +64 -19
package/package.json
CHANGED
package/src/commands/chat.js
CHANGED
|
@@ -292,6 +292,9 @@ async function chat(botName, options = {}) {
|
|
|
292
292
|
|
|
293
293
|
const memory = loadMemory(bot.id);
|
|
294
294
|
console.log(chalk.yellow('\nHafıza:\n'));
|
|
295
|
+
if (memory.botName) {
|
|
296
|
+
console.log(chalk.cyan(' Bot Adı:'), chalk.white(memory.botName));
|
|
297
|
+
}
|
|
295
298
|
if (memory.name) {
|
|
296
299
|
console.log(chalk.cyan(' İsim:'), chalk.white(memory.name));
|
|
297
300
|
}
|
|
@@ -309,7 +312,7 @@ async function chat(botName, options = {}) {
|
|
|
309
312
|
console.log(chalk.white(` • ${f.value}`) + chalk.gray(` (skor: ${f.score})`));
|
|
310
313
|
});
|
|
311
314
|
}
|
|
312
|
-
if (!memory.name && memory.preferences.length === 0 && memory.facts.length === 0) {
|
|
315
|
+
if (!memory.botName && !memory.name && memory.preferences.length === 0 && memory.facts.length === 0) {
|
|
313
316
|
console.log(chalk.gray(' Henüz hafıza yok'));
|
|
314
317
|
}
|
|
315
318
|
console.log('');
|
|
@@ -211,7 +211,7 @@ body::before{
|
|
|
211
211
|
<div class="header-bot-name" id="header-bot-name">Nature Bot</div>
|
|
212
212
|
<div class="header-bot-model" id="header-bot-model">NatureCo</div>
|
|
213
213
|
</div>
|
|
214
|
-
<div class="version-badge" id="version-badge">v2.4.
|
|
214
|
+
<div class="version-badge" id="version-badge">v2.4.4</div>
|
|
215
215
|
</div>
|
|
216
216
|
<div class="messages" id="messages"></div>
|
|
217
217
|
<div class="input-area">
|
|
@@ -341,7 +341,7 @@ function dashboard(action) {
|
|
|
341
341
|
apiKey: cfg.apiKey,
|
|
342
342
|
defaultBot: cfg.defaultBot,
|
|
343
343
|
defaultBotId: cfg.defaultBotId,
|
|
344
|
-
version: 'v2.4.
|
|
344
|
+
version: 'v2.4.4',
|
|
345
345
|
bots: cfg.bots || [],
|
|
346
346
|
telegramToken: cfg.telegramToken || null,
|
|
347
347
|
whatsappConnected: cfg.whatsappConnected || false,
|
|
@@ -128,7 +128,7 @@ async function startGateway() {
|
|
|
128
128
|
|
|
129
129
|
async function runGatewayWorker() {
|
|
130
130
|
// This runs in the background
|
|
131
|
-
log('gateway', 'Starting NatureCo Gateway v2.4.
|
|
131
|
+
log('gateway', 'Starting NatureCo Gateway v2.4.4...', 'green');
|
|
132
132
|
|
|
133
133
|
// Load config
|
|
134
134
|
const { getConfig } = require('../utils/config');
|
package/src/utils/api.js
CHANGED
package/src/utils/memory.js
CHANGED
|
@@ -24,6 +24,7 @@ function loadMemory(botId) {
|
|
|
24
24
|
if (!fs.existsSync(filePath)) {
|
|
25
25
|
return {
|
|
26
26
|
name: null,
|
|
27
|
+
botName: null,
|
|
27
28
|
preferences: [],
|
|
28
29
|
facts: [],
|
|
29
30
|
lastSeen: null,
|
|
@@ -42,10 +43,16 @@ function loadMemory(botId) {
|
|
|
42
43
|
memory.facts = memory.facts.map(f => ({ value: f, score: 5, updatedAt: new Date().toISOString() }));
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
// Ensure botName field exists
|
|
47
|
+
if (!memory.hasOwnProperty('botName')) {
|
|
48
|
+
memory.botName = null;
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
return memory;
|
|
46
52
|
} catch {
|
|
47
53
|
return {
|
|
48
54
|
name: null,
|
|
55
|
+
botName: null,
|
|
49
56
|
preferences: [],
|
|
50
57
|
facts: [],
|
|
51
58
|
lastSeen: null,
|
|
@@ -72,6 +79,8 @@ function addMemoryEntry(botId, key, value) {
|
|
|
72
79
|
|
|
73
80
|
if (key === 'name') {
|
|
74
81
|
memory.name = value;
|
|
82
|
+
} else if (key === 'botName') {
|
|
83
|
+
memory.botName = value;
|
|
75
84
|
} else if (key === 'preference') {
|
|
76
85
|
// Check for duplicate
|
|
77
86
|
const existing = memory.preferences.find(p => p.value.toLowerCase() === value.toLowerCase());
|
|
@@ -119,21 +128,47 @@ function addMemoryEntry(botId, key, value) {
|
|
|
119
128
|
function extractMemoryFromMessage(message) {
|
|
120
129
|
const extracted = [];
|
|
121
130
|
|
|
122
|
-
//
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
// Question words that should NOT trigger name extraction
|
|
132
|
+
const questionWords = ['ne', 'kim', 'nasıl', 'neden', 'niçin', 'nerede', 'nereye', 'nereden', 'hangi', 'kaç', 'ne zaman'];
|
|
133
|
+
|
|
134
|
+
// Check if message is a question
|
|
135
|
+
const isQuestion = questionWords.some(q => message.toLowerCase().includes(q)) || message.includes('?');
|
|
136
|
+
|
|
137
|
+
// Bot name patterns: "senin adın X", "sana X diyeceğim", "adın X olsun"
|
|
138
|
+
const botNamePatterns = [
|
|
139
|
+
/senin\s+ad[ıi]n\s+([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)/i,
|
|
140
|
+
/sana\s+([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)\s+diyece[ğg]im/i,
|
|
141
|
+
/ad[ıi]n\s+([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)\s+olsun/i,
|
|
142
|
+
/seni\s+([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)\s+olarak\s+çağ[ıi]raca[ğg][ıi]m/i,
|
|
127
143
|
];
|
|
128
144
|
|
|
129
|
-
for (const pattern of
|
|
145
|
+
for (const pattern of botNamePatterns) {
|
|
130
146
|
const match = message.match(pattern);
|
|
131
147
|
if (match) {
|
|
132
|
-
extracted.push({ key: '
|
|
148
|
+
extracted.push({ key: 'botName', value: match[1] });
|
|
133
149
|
break;
|
|
134
150
|
}
|
|
135
151
|
}
|
|
136
152
|
|
|
153
|
+
// Name patterns: "adım X", "ben X'im", "ismim X", "benim adım X"
|
|
154
|
+
// Only extract if NOT a question
|
|
155
|
+
if (!isQuestion) {
|
|
156
|
+
const namePatterns = [
|
|
157
|
+
/benim\s+ad[ıi]m\s+([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)/i,
|
|
158
|
+
/ad[ıi]m\s+([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)/i,
|
|
159
|
+
/ben\s+([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)['']?[ıi]?m/i,
|
|
160
|
+
/[iı]smim\s+([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)/i,
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
for (const pattern of namePatterns) {
|
|
164
|
+
const match = message.match(pattern);
|
|
165
|
+
if (match) {
|
|
166
|
+
extracted.push({ key: 'name', value: match[1] });
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
137
172
|
// Location patterns: "X'te yaşıyorum", "X'de yaşıyorum"
|
|
138
173
|
const locationPatterns = [
|
|
139
174
|
/([A-ZÇĞİÖŞÜ][a-zçğıöşü]+)['']?[td]e\s+ya[şs][ıi]yorum/i,
|
|
@@ -161,24 +196,34 @@ function extractMemoryFromMessage(message) {
|
|
|
161
196
|
function getMemoryPrompt(botId) {
|
|
162
197
|
const memory = loadMemory(botId);
|
|
163
198
|
|
|
164
|
-
if (!memory.name && memory.preferences.length === 0 && memory.facts.length === 0) {
|
|
199
|
+
if (!memory.name && !memory.botName && memory.preferences.length === 0 && memory.facts.length === 0) {
|
|
165
200
|
return '';
|
|
166
201
|
}
|
|
167
202
|
|
|
168
|
-
const parts = [
|
|
203
|
+
const parts = [];
|
|
169
204
|
|
|
170
|
-
|
|
171
|
-
|
|
205
|
+
// Add bot name if set
|
|
206
|
+
if (memory.botName) {
|
|
207
|
+
parts.push(`Your name is ${memory.botName}.`);
|
|
172
208
|
}
|
|
173
209
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
parts.push(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
210
|
+
// Add user memory section
|
|
211
|
+
if (memory.name || memory.preferences.length > 0 || memory.facts.length > 0) {
|
|
212
|
+
parts.push('## Kullanıcı Hafızası');
|
|
213
|
+
|
|
214
|
+
if (memory.name) {
|
|
215
|
+
parts.push(`İsim: ${memory.name}`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (memory.preferences.length > 0) {
|
|
219
|
+
const sorted = memory.preferences.sort((a, b) => b.score - a.score);
|
|
220
|
+
parts.push(`Tercihler: ${sorted.map(p => p.value).join(', ')}`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (memory.facts.length > 0) {
|
|
224
|
+
const sorted = memory.facts.sort((a, b) => b.score - a.score);
|
|
225
|
+
parts.push(`Bilgiler: ${sorted.map(f => f.value).join(', ')}`);
|
|
226
|
+
}
|
|
182
227
|
}
|
|
183
228
|
|
|
184
229
|
return parts.join('\n');
|