Skip to content

Commit 36b0b29

Browse files
whipser030黑布林CaralHsifridayL
authored
patch:deduplicate add items (#725)
* update reader and search strategy * set strategy reader and search config * fix install problem * fix * fix test * turn off graph recall * turn off graph recall * turn off graph recall * fix Searcher input bug * fix Searcher * fix Search * fix bug * adjust strategy reader * adjust strategy reader * adjust search config input * reformat code * re pr * format repair * fix time issue * develop feedback process * feedback handler configuration * upgrade feedback using * add threshold * update prompt * update prompt * fix handler * add feedback scheduler * add handler change node update * add handler change node update * add handler change node update * add handler change node update * fix interface input * add chunk and ratio filter * update stopwords * fix messages queue * add seach_by_keywords_LIKE * add doc filter * add retrieve query * add retrieve queies * patch info filter * add log and make embedding safety net * add log and make embedding safety net * deduplicate add objects * use _add_memories_parallel * delete Special characters * delete Special characters * delete Special characters * delete Special characters --------- Co-authored-by: 黑布林 <[email protected]> Co-authored-by: CaralHsi <[email protected]> Co-authored-by: chunyu li <[email protected]>
1 parent 8ea4828 commit 36b0b29

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/memos/mem_feedback/feedback.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import concurrent.futures
2+
import copy
23
import difflib
34
import json
45
import re
@@ -331,7 +332,7 @@ def semantics_feedback(
331332
current_memories = [
332333
item for item in current_memories if self._info_comparison(item, info, include_keys)
333334
]
334-
335+
operations = []
335336
if not current_memories:
336337
operations = [{"operation": "ADD"}]
337338
logger.warning(
@@ -371,6 +372,21 @@ def semantics_feedback(
371372

372373
operations = self.standard_operations(all_operations, current_memories)
373374

375+
add_texts = []
376+
final_operations = []
377+
for item in operations:
378+
if item["operation"].lower() == "add" and "text" in item and item["text"]:
379+
if item["text"] in add_texts:
380+
continue
381+
final_operations.append(item)
382+
add_texts.append(item["text"])
383+
elif item["operation"].lower() == "update":
384+
final_operations.append(item)
385+
logger.info(
386+
f"[Feedback Core: deduplicate add] {len(operations)} -> {len(final_operations)} memories"
387+
)
388+
operations = copy.deepcopy(final_operations)
389+
374390
logger.info(f"[Feedback Core Operations]: {operations!s}")
375391

376392
if not operations:
@@ -621,6 +637,7 @@ def correct_item(data):
621637

622638
dehallu_res = [correct_item(item) for item in operations]
623639
dehalluded_operations = [item for item in dehallu_res if item]
640+
logger.info(f"[Feedback Core: dehalluded_operations] {dehalluded_operations}")
624641

625642
# c add objects
626643
add_texts = []

0 commit comments

Comments
 (0)