vault backup: 2026-02-26 21:10:47

This commit is contained in:
windyboy
2026-02-26 21:10:47 +08:00
parent 1e3905d304
commit 410167d3b4
38 changed files with 3890 additions and 70 deletions
+3 -2
View File
@@ -9,7 +9,7 @@ def sanitize(text: str) -> str:
return text.replace('```', '` ` `').strip()
def query(text: str, top_k: int = 5, max_chars: int = 2500) -> str:
def query(text: str, top_k: int = 5, max_chars: int = 2500, threshold: float = 0.5) -> str:
embedding = embed_text(text)
vector = vector_literal(embedding)
@@ -19,10 +19,11 @@ def query(text: str, top_k: int = 5, max_chars: int = 2500) -> str:
'''
SELECT source, content
FROM memory_primary
WHERE embedding <=> %s::vector < %s
ORDER BY embedding <=> %s::vector
LIMIT %s
''',
(vector, top_k),
(vector, threshold, vector, top_k),
)
rows = cur.fetchall()