sieve-memory 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sieve/__init__.py ADDED
@@ -0,0 +1,43 @@
1
+ """
2
+ Sieve — a fast, local, calibrated memory-curation layer for AI agents.
3
+
4
+ Sieve continuously scores memories (importance, staleness, actionability, category)
5
+ using calibrated local inference or lightweight heuristics, so agent memory
6
+ prunes and curates itself instead of growing unboundedly or requiring costly
7
+ per-item LLM calls.
8
+ """
9
+
10
+ from .memory import SieveMemory
11
+ from .pipeline import SievePipeline
12
+ from .policy import PolicyConfig, PolicyEngine
13
+ from .scorer import ItemScores, MockScorer, Scorer
14
+ from .store import Item, Store
15
+ from .sweep import SweepResult, redundancy_sweep, staleness_sweep
16
+ from .worker import SieveWorker
17
+
18
+ __version__ = "0.1.0"
19
+
20
+ __all__ = [
21
+ "SieveMemory",
22
+ "SievePipeline",
23
+ "SieveWorker",
24
+ "PolicyConfig",
25
+ "PolicyEngine",
26
+ "ItemScores",
27
+ "MockScorer",
28
+ "LayaScorer",
29
+ "Scorer",
30
+ "Item",
31
+ "Store",
32
+ "SweepResult",
33
+ "staleness_sweep",
34
+ "redundancy_sweep",
35
+ "__version__",
36
+ ]
37
+
38
+
39
+ def __getattr__(name: str):
40
+ if name == "LayaScorer":
41
+ from .scorer import LayaScorer
42
+ return LayaScorer
43
+ raise AttributeError(f"module 'sieve' has no attribute '{name}'")
sieve/__main__.py ADDED
@@ -0,0 +1,4 @@
1
+ from sieve.cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,4 @@
1
+ from .base import Adapter, RawItem
2
+ from .json_file import JSONFileAdapter
3
+
4
+ __all__ = ["Adapter", "RawItem", "JSONFileAdapter"]
sieve/adapters/base.py ADDED
@@ -0,0 +1,30 @@
1
+ """
2
+ Source adapters: turn "whatever your memory system looks like" into a
3
+ stream of (id, source, text, metadata) tuples that Sieve can ingest.
4
+
5
+ This is the whole point of keeping Sieve decoupled from any one project
6
+ (Atlas, a RAG store, a Slack export, a raw agent scratchpad) — write one
7
+ small adapter per source, everything downstream (scoring, policy, sweeps,
8
+ API) is shared.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from abc import ABC, abstractmethod
14
+ from typing import Iterator, NamedTuple, Optional
15
+
16
+
17
+ class RawItem(NamedTuple):
18
+ id: str
19
+ source: str
20
+ text: str
21
+ metadata: Optional[dict] = None
22
+ namespace: str = "default"
23
+
24
+
25
+ class Adapter(ABC):
26
+ @abstractmethod
27
+ def stream(self) -> Iterator[RawItem]:
28
+ """Yield items to ingest. Called once per sync; adapters that
29
+ support incremental sync should track their own cursor/offset."""
30
+ ...
@@ -0,0 +1,37 @@
1
+ """
2
+ Reference adapter: reads a flat JSON array of items.
3
+
4
+ Expected format:
5
+ [
6
+ {"id": "conv1-turn3", "text": "...", "metadata": {...}},
7
+ ...
8
+ ]
9
+
10
+ This is the adapter used by examples/run_v0.py. Use it as the template
11
+ for a real adapter (chat log webhook, vector DB cursor, file watcher).
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ from pathlib import Path
18
+ from typing import Iterator
19
+
20
+ from .base import Adapter, RawItem
21
+
22
+
23
+ class JSONFileAdapter(Adapter):
24
+ def __init__(self, path: str, source_name: str = "json_file"):
25
+ self.path = Path(path)
26
+ self.source_name = source_name
27
+
28
+ def stream(self) -> Iterator[RawItem]:
29
+ data = json.loads(self.path.read_text())
30
+ for entry in data:
31
+ yield RawItem(
32
+ id=entry["id"],
33
+ source=self.source_name,
34
+ text=entry["text"],
35
+ metadata=entry.get("metadata", {}),
36
+ namespace=entry.get("namespace", "default"),
37
+ )