Lancedb Memory
Skill by pntrivedy
Install via CLI (Recommended)
clawhub install openclaw/skills/skills/pntrivedy/lancedb-memory#!/usr/bin/env python3 """ LanceDB integration for long-term memory management. Provides vector search and semantic memory capabilities. """
import os import json import lancedb from datetime import datetime from typing import List, Dict, Any, Optional from pathlib import Path
class LanceMemoryDB: """LanceDB wrapper for long-term memory storage and retrieval."""
def __init__(self, db_path: str = "/Users/prerak/clawd/memory/lancedb"):
self.db_path = Path(db_path)
self.db_path.mkdir(parents=True, exist_ok=True)
self.db = lancedb.connect(self.db_path)
# Ensure memory table exists
if "memory" not in self.db.table_names():
self._create_memory_table()
def _create_memory_table(self):
"""Create the memory table with appropriate schema."""
schema = [
{"name": "id", "type": "int", "nullable": False},
{"name": "timestamp", "type": "timestamp", "nullable": False},
{"name": "content", "type": "str", "nullable": False},
{"name": "category", "type": "str", "nullable": True},
{"name": "tags", "type": "str[]", "nullable": True},
{"name": "importance", "type": "int", "nullable": True},
{"name": "metadata", "type": "json", "nullable": True},
]
self.db.create_table("memory", schema=schema)
def add_memory(self, content: str, category: str = "general", tags: List[str] = None,
importance: int = 5, metadata: Dict[str, Any] = None) -> int:
"""Add a new memory entry."""
table = self.db.open_table("memory")
# Get next ID
max_id = table.to_pandas()["id"].max() if len(table) > 0 else 0
new_id = max_id + 1
# Insert new memory
memory_data = {
"id": new_id,
"timestamp": datetime.now(),
"content": content,
"category": category,
"tags": tags or [],
"importance": importance,
"metadata": metadata or {}
}
table.add([memory_data])
return new_id
def search_memories(self, query: str, category: str = None, limit: int = 10) -> List[Dict]:
"""Search memories using vector similarity."""
table = self.db.open_table("memory")
# Build filter
where_clause = []
if category:
where_clause.append(f"category = '{category}'")
filter_expr = " AND ".join(where_clause) if where_clause else None
# Vector search
results = table.vector_search(query).limit(limit).where(filter_expr).to_list()
return results
def get_memories_by_category(self, category: str, limit: int = 50) -> List[Dict]:
"""Get memories by category."""
table = self.db.open_table("memory")
df = table.to_pandas()
filtered = df[df["category"] == category]....
Metadata
Not sure this is the right skill?
Describe what you want to build — we'll match you to the best skill from 16,000+ options.
Find the right skillPaste this into your clawhub.json to enable this plugin.
{
"plugins": {
"official-pntrivedy-lancedb-memory": {
"enabled": true,
"auto_update": true
}
}
}Related Skills
self-improvement
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Claude ('No, that's wrong...', 'Actually...'), (3) User requests a capability that doesn't exist, (4) An external API or tool fails, (5) Claude realizes its knowledge is outdated or incorrect, (6) A better approach is discovered for a recurring task. Also review learnings before major tasks.
auto-updater
Automatically update Clawdbot and all installed skills once daily. Runs via cron, checks for updates, applies them, and messages the user with a summary of what changed.
parallel
High-accuracy web search and research via Parallel.ai API. Optimized for AI agents with rich excerpts and citations.
n8n
Manage n8n workflows and automations via API. Use when working with n8n workflows, executions, or automation tasks - listing workflows, activating/deactivating, checking execution status, manually triggering workflows, or debugging automation issues.