Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mempalace/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def cmd_mine(args):
dry_run=args.dry_run,
respect_gitignore=not args.no_gitignore,
include_ignored=include_ignored,
workers=args.workers,
)


Expand Down Expand Up @@ -450,6 +451,12 @@ def main():
default="exchange",
help="Extraction strategy for convos mode: 'exchange' (default) or 'general' (5 memory types)",
)
p_mine.add_argument(
"--workers",
type=int,
default=0,
help="Parallel workers for file processing (default: min(8, cpu_count); 1 = sequential)",
)

# search
p_search = sub.add_parser("search", help="Find anything, exact words")
Expand Down
50 changes: 28 additions & 22 deletions mempalace/convo_miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,37 +326,43 @@ def mine_convos(
if extract_mode != "general":
room_counts[room] += 1

# File each chunk
drawers_added = 0
# Batch all chunks into a single add call per file
batch_docs = []
batch_ids = []
batch_metas = []
for chunk in chunks:
chunk_room = chunk.get("memory_type", room) if extract_mode == "general" else room
if extract_mode == "general":
room_counts[chunk_room] += 1
drawer_id = f"drawer_{wing}_{chunk_room}_{hashlib.sha256((source_file + str(chunk['chunk_index'])).encode()).hexdigest()[:24]}"
try:
batch_docs.append(chunk["content"])
batch_ids.append(drawer_id)
batch_metas.append(
{
"wing": wing,
"room": chunk_room,
"source_file": source_file,
"chunk_index": chunk["chunk_index"],
"added_by": agent,
"filed_at": datetime.now().isoformat(),
"ingest_mode": "convos",
"extract_mode": extract_mode,
}
)
drawers_added = 0
_ADD_BATCH_SIZE = 100
if batch_docs:
for batch_start in range(0, len(batch_docs), _ADD_BATCH_SIZE):
batch_end = batch_start + _ADD_BATCH_SIZE
Comment on lines +352 to +356

Copilot AI Apr 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ADD_BATCH_SIZE is redefined on every file iteration. Since it’s a constant, consider moving it to module scope (or at least defining it once outside the per-file loop) to keep the hot path simpler and avoid repeated rebinding.

Copilot uses AI. Check for mistakes.
collection.upsert(
documents=[chunk["content"]],
ids=[drawer_id],
metadatas=[
{
"wing": wing,
"room": chunk_room,
"source_file": source_file,
"chunk_index": chunk["chunk_index"],
"added_by": agent,
"filed_at": datetime.now().isoformat(),
"ingest_mode": "convos",
"extract_mode": extract_mode,
}
],
documents=batch_docs[batch_start:batch_end],
ids=batch_ids[batch_start:batch_end],
metadatas=batch_metas[batch_start:batch_end],
)
drawers_added += 1
except Exception as e:
if "already exists" not in str(e).lower():
raise
drawers_added += len(batch_docs[batch_start:batch_end])

total_drawers += drawers_added
print(f" [{i:4}/{len(files)}] {filepath.name[:50]:50} +{drawers_added}")
print(f" + [{i:4}/{len(files)}] {filepath.name[:50]:50} +{drawers_added}")

print(f"\n{'=' * 55}")
print(" Done.")
Expand Down
72 changes: 72 additions & 0 deletions mempalace/entity_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,78 @@
"networks",
"training",
"inference",
# Common technical/documentation terms that appear capitalized but aren't entities
"handler",
"node",
"service",
"manager",
"client",
"server",
"worker",
"plugin",
"module",
"interface",
"event",
"request",
"response",
"update",
"config",
"builder",
"factory",
"component",
"controller",
"provider",
"wrapper",
"helper",
"util",
"parser",
"loader",
"renderer",
"adapter",
"proxy",
"listener",
"observer",
"validator",
"formatter",
"converter",
"resolver",
"selector",
"reducer",
"dispatcher",
"compiler",
"optimizer",
"analyzer",
"generator",
"template",
"registry",
"repository",
"gateway",
"middleware",
"pipeline",
"container",
"context",
"session",
"token",
"stream",
"buffer",
"cache",
"queue",
"schema",
"entity",
"instance",
"object",
"method",
"property",
"attribute",
"parameter",
"argument",
"variable",
"constant",
"function",
"package",
"framework",
"runtime",
"platform",
}

# For entity detection — prose only, no code files
Expand Down
Loading
Loading