Default search without Voyage AI — semantic=False by default

Full-text search is the default (fast, no API calls).
Pass semantic=True explicitly when vector similarity is needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 06:53:53 +02:00
parent 797de01e60
commit 0d3407e664
+8 -4
View File
@@ -388,10 +388,12 @@ def search(
limit: int = 10,
min_importance: float = 0.0,
include_sessions: bool = False,
semantic: bool = False,
) -> str:
"""
Hybridní vyhledávání v paměti.
Kombinuje full-text (vždy) + vektorové sémantické (pokud embeddingy dostupné).
Vyhledávání v paměti.
Default: full-text (tsvector) — rychlé, bez API volání.
semantic=True: přidá vektorové sémantické vyhledávání přes Voyage AI (pomalejší).
query: přirozený jazyk nebo klíčová slova
types: ['fact','decision','preference','summary','document','email','project','person']
@@ -444,8 +446,8 @@ def search(
fts_ids = {r["id"] for r in rows}
results = [_row_to_dict(r) for r in rows]
# ── Vector search (nativní pgvector, <=> cosine distance) ──
query_emb = get_embedding(query)
# ── Vector search (pouze pokud semantic=True) ──
query_emb = get_embedding(query) if semantic else None
if query_emb:
try:
import numpy as np
@@ -520,6 +522,7 @@ def get_context(
project: Optional[str] = None,
limit: int = 8,
include_preferences: bool = True,
semantic: bool = False,
) -> str:
"""
Vrátí nejrelevantnější paměti pro daný kontext/téma.
@@ -537,6 +540,7 @@ def get_context(
project=project,
limit=limit,
min_importance=0.3,
semantic=semantic,
)
parts.append("=== RELEVANTNÍ PAMĚTI ===\n" + main_result)