-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.js
More file actions
179 lines (146 loc) · 6.79 KB
/
config.js
File metadata and controls
179 lines (146 loc) · 6.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/**
* @file brain_synapse/config.js
* @description Central configuration file for managing all tunable parameters
*
* ==================== Configuration Guide ====================
*
* This file contains all configurable options for the brain_synapse system.
* The open-source version has removed all private information - configure as needed.
*
* 【Local-Only Mode】
* - The system can run fully locally without any API Key!
* - When vector search is not configured, the system falls back to local file search
* - All memory functions (distillation, associative recall, forgetting cycles, etc.) work normally
*
* ==================== Configuration Options ====================
*/
// ==================== Vector Search API Configuration ====================
// 【Optional】Configure to enable semantic vector search
// Set environment variable: export VECTOR_API_KEY='your-key'
// Or modify vectorSearchApi.apiKey directly in this file
const CONFIG = {
// ==================== Core Configuration ====================
// Workspace directory - points to the directory containing the memory folder
workspaceRoot: null, // Auto-detected at runtime
// Active memory storage path
weightsFile: 'synapse_weights.json',
// Cold storage memory path (forgotten memories)
latentWeightsFile: 'latent_weights.json',
// ==================== LTD (Long-Term Depression) Forgetting Cycle Parameters ====================
// 【Beginner Safe Testing Mode - Designed for early testing】
//
// [Why Conservative Settings]
// When first installing the system, most people will test randomly. If the AI learns too quickly
// and retains memories too long, it will solidify incorrect tests into garbage memories,
// even causing Token waste.
//
// [Parameter Description]
// - decayRate 0.90: Faster forgetting rate, half-life ~7 turns
// - forgetThreshold 0.2: Easier to move to cold storage, prevents dirty data pollution
// - minObservationsForInstinct 5: Conservative threshold, prevents "random testing" from becoming "truth"
//
ltd: {
// Weight decay rate per forgetting cycle
// [Beginner Safe Config] 0.90 = 10% decay per turn, half-life ~7 turns
// Fast forgetting suitable for early testing, ensures context stays minimal, saves Tokens
decayRate: 0.90,
// Below this weight value, memory moves to cold storage
// [Beginner Safe Config] 0.2 higher threshold, unused memories quickly move to cold storage, extreme Token saving
forgetThreshold: 0.2,
// Initial weight when reviving from cold storage
revivedWeight: 0.5,
// Initial weight for new memories
initialWeight: 1.0
},
// ==================== Vector Search API Configuration ====================
// 【Optional】Configure to enable semantic search
vectorSearchApi: {
// API URL
apiUrl: 'https://api-inference.huggingface.co/pipeline/feature-extraction/BAAI/bge-m3',
// Vector model selection
model: 'BAAI/bge-m3',
// API Key - supports environment variable or direct fill
// If not configured, system will automatically fall back to local search
apiKey: process.env.VECTOR_API_KEY || '',
// Timeout setting (milliseconds)
timeout: 5000,
// Maximum number of results
maxResults: 5,
// Text chunk size
chunkSize: 1000
},
// ==================== Local File Search Configuration ====================
// 【Required】No API Key needed, runs completely locally
localSearch: {
// Maximum execution time (milliseconds)
// Prevents search from consuming too many resources
maxExecutionTime: 100,
// Cache file path
cacheFile: 'local_index_cache.json'
},
// ==================== Observer Mode Configuration ====================
// 【Beginner Safe Testing Mode - Conservative subconscious solidification】
//
// [Why Conservative Settings]
// Beginners often test randomly early on. If threshold is too low, AI will treat your "random testing" as "truth"
// and solidify it into garbage instincts. Setting to 5 times effectively prevents mislearning.
//
observer: {
// Minimum observations required to create an Instinct
// [Beginner Safe Config] 5 times conservative threshold, prevents test behavior from becoming instinct
// During early testing, behavior is unstable, need more observations to confirm real patterns
minObservationsForInstinct: 5,
// Confidence parameters
confidenceBase: 0.3, // Base confidence
confidenceIncrement: 0.05, // Increment per positive feedback
confidenceDecrement: 0.1, // Decrement per negative feedback
confidenceDecayWeekly: 0.02 // Natural weekly decay
},
// ==================== Keyword Extraction Configuration ====================
keywords: {
// Minimum word length
minWordLength: 2,
// Maximum weight multiplier
// Prevents any single word from dominating retrieval due to excessive weight
maxWeightMultiplier: 2.0,
// Decay factor
decayFactor: 0.1,
// Valid POS tags
validPosTags: ['n', 'nr', 'nz', 'eng', 'noun', 'NN', 'NNS', 'NNP', 'NNPS', 'FW']
},
// ==================== Feature Toggles ====================
features: {
// Enable vector search (requires API Key configuration)
// Auto-detect: enabled if valid API Key exists
enableVectorSearch: !!process.env.VECTOR_API_KEY,
// Enable Observer mode (automatically learn user behavior)
enableObserver: true,
// Enable automatic distillation
enableAutoDistill: true
}
};
// Auto-detect workspace directory
const path = require('path');
const fs = require('fs');
function detectWorkspaceRoot() {
// Try to find by searching upward from current directory
let currentDir = __dirname;
for (let i = 0; i < 5; i++) {
const memoryDir = path.join(currentDir, 'workspace', 'memory');
if (fs.existsSync(memoryDir)) {
return currentDir;
}
const parent = path.dirname(currentDir);
if (parent === currentDir) break;
currentDir = parent;
}
// Default to parent directory
return path.resolve(__dirname, '..');
}
// Initialize workspace directory
CONFIG.workspaceRoot = detectWorkspaceRoot();
// Auto-enable vector search if API Key exists in environment variables
if (process.env.VECTOR_API_KEY || process.env.EMBEDDING_API_KEY) {
CONFIG.features.enableVectorSearch = true;
}
module.exports = CONFIG;