forked from asi-alliance/OmegaClaw-Core
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmemory.metta
More file actions
49 lines (40 loc) · 1.96 KB
/
Copy pathmemory.metta
File metadata and controls
49 lines (40 loc) · 1.96 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
;Configured at runtime memory and history in amount of characters:
(= (maxFeedback) (empty))
(= (maxRecallItems) (empty))
(= (maxEpisodeRecallLines) (empty))
(= (maxHistory) (empty))
(= (embeddingprovider) (empty))
(= (initMemory)
(progn (println! "Initializing memory")
(configure maxFeedback 50000)
(configure maxRecallItems 20)
(configure maxEpisodeRecallLines 20)
(configure maxHistory 30000)
(configure embeddingprovider Local) ;OpenAI or Local
(if (== (embeddingprovider) Local)
(py-call (lib_llm_ext.initLocalEmbedding)) _)))
(= (getPrompt)
(read-file (library OmegaClaw-Core ./memory/prompt.txt)))
(= (getHistory)
(read_file_tail (library OmegaClaw-Core ./memory/history.metta) (maxHistory)))
(= (addToHistory $lastmessage $response $sexpr $msgnew)
(if $msgnew
(if (== (get-state &error) ())
(appendToHistory ((get_time_as_string) (newline) "HUMAN_MESSAGE: " $lastmessage (newline) $response (newline)))
(appendToHistory ((get_time_as_string) (newline) "HUMAN_MESSAGE: " $lastmessage (newline) $response (newline) ERROR_FEEDBACK: (get-state &error))))
(if (== (get-state &error) ())
(appendToHistory ((get_time_as_string) (newline) $response (newline)))
(appendToHistory ((get_time_as_string) (newline) $response (newline) ERROR_FEEDBACK: (get-state &error))))))
(= (embed $str)
(if (== (embeddingprovider) Local)
(py-call (lib_llm_ext.useLocalEmbedding (string-safe $str)))
(useGPTEmbedding (string-safe $str))))
(= (appendToHistory $addition)
(append-file (library OmegaClaw-Core ./memory/history.metta) (swrite $addition)))
(= (remember $str)
(progn (py-call (lib_chromadb.remember $str (embed $str) (get_time_as_string)))
REMEMBER-SUCCESS))
(= (query $str)
(py-call (lib_chromadb.query (embed $str) (maxRecallItems))))
(= (episodes $time)
(py-call (helper.around_time $time (maxEpisodeRecallLines))))