Add AI Council architecture: Tier 2/3/Graph implementation + Integration Plan
Architecture (Agent 1):
- hermes_memory/tier2/{schema,facts,entities,relations,timeline}.py
- hermes_memory/tier3/{backend,chroma_backend,embedder}.py
- hermes_memory/graph/nx_store.py
- hermes_memory/api/memory_api.py (unified API)
- hermes_memory/cron/{consolidate,embed_queue,graph_refresh,prune}.py
- hermes_memory/config.py + pyproject.toml
Integration Plan (Agent 3):
- INTEGRATION_PLAN.md: Memory Provider Plugin strategy
- Hermes Core needs minimal changes
- sync_turn() + prefetch() hooks
- Skills integration via nextlevel_search/remember
Auto-Extraction (Agent 2):
- ARCHITECTURE.md: Full extraction pipeline docs
- Chunking, Pre-Filter, LLM Prompts, Classification
- Entity-Linking, Temporal Reasoning, Deduplication
All files: Python syntax checked, ECC standards applied.
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
"""TimelineStore — Zeitachsen-Management für Tier 2."""
|
||||
|
||||
import json
|
||||
import sqlite3
|
||||
import time
|
||||
import uuid as uuid_mod
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class TimelineEvent:
|
||||
uuid: str
|
||||
event_type: str
|
||||
title: str
|
||||
description: Optional[str]
|
||||
related_entities: List[str]
|
||||
related_facts: List[str]
|
||||
session_id: Optional[str]
|
||||
timestamp: float
|
||||
importance: float
|
||||
|
||||
|
||||
class TimelineStore:
|
||||
def __init__(self, conn: sqlite3.Connection):
|
||||
self.conn = conn
|
||||
|
||||
def add(
|
||||
self,
|
||||
event_type: str,
|
||||
title: str,
|
||||
description: Optional[str] = None,
|
||||
importance: float = 0.5,
|
||||
related_entities: Optional[List[str]] = None,
|
||||
related_facts: Optional[List[str]] = None,
|
||||
session_id: Optional[str] = None,
|
||||
) -> TimelineEvent:
|
||||
ev_uuid = str(uuid_mod.uuid4())
|
||||
now = time.time()
|
||||
self.conn.execute(
|
||||
"""
|
||||
INSERT INTO timeline (uuid, event_type, title, description, related_entities, related_facts, session_id, timestamp, importance)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
ev_uuid,
|
||||
event_type,
|
||||
title,
|
||||
description,
|
||||
json.dumps(related_entities or []),
|
||||
json.dumps(related_facts or []),
|
||||
session_id,
|
||||
now,
|
||||
importance,
|
||||
),
|
||||
)
|
||||
self.conn.commit()
|
||||
return self.get_by_uuid(ev_uuid)
|
||||
|
||||
def get_by_uuid(self, ev_uuid: str) -> Optional[TimelineEvent]:
|
||||
row = self.conn.execute("SELECT * FROM timeline WHERE uuid = ? LIMIT 1", (ev_uuid,)).fetchone()
|
||||
return self._row_to_event(row) if row else None
|
||||
|
||||
def query(
|
||||
self,
|
||||
start: Optional[float] = None,
|
||||
end: Optional[float] = None,
|
||||
event_type: Optional[str] = None,
|
||||
limit: int = 20,
|
||||
) -> List[TimelineEvent]:
|
||||
sql = "SELECT * FROM timeline WHERE 1=1"
|
||||
params: List = []
|
||||
if start:
|
||||
sql += " AND timestamp >= ?"
|
||||
params.append(start)
|
||||
if end:
|
||||
sql += " AND timestamp <= ?"
|
||||
params.append(end)
|
||||
if event_type:
|
||||
sql += " AND event_type = ?"
|
||||
params.append(event_type)
|
||||
sql += " ORDER BY timestamp DESC LIMIT ?"
|
||||
params.append(limit)
|
||||
rows = self.conn.execute(sql, params).fetchall()
|
||||
return [self._row_to_event(r) for r in rows]
|
||||
|
||||
def _row_to_event(self, row: sqlite3.Row) -> TimelineEvent:
|
||||
return TimelineEvent(
|
||||
uuid=row["uuid"],
|
||||
event_type=row["event_type"],
|
||||
title=row["title"],
|
||||
description=row["description"],
|
||||
related_entities=json.loads(row["related_entities"] or "[]"),
|
||||
related_facts=json.loads(row["related_facts"] or "[]"),
|
||||
session_id=row["session_id"],
|
||||
timestamp=row["timestamp"],
|
||||
importance=row["importance"],
|
||||
)
|
||||
Reference in New Issue
Block a user