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 +43 -0
- sieve/__main__.py +4 -0
- sieve/adapters/__init__.py +4 -0
- sieve/adapters/base.py +30 -0
- sieve/adapters/json_file.py +37 -0
- sieve/api.py +667 -0
- sieve/assets/favicon.png +0 -0
- sieve/assets/favicon.svg +15 -0
- sieve/assets/icon.png +0 -0
- sieve/assets/logo-black.svg +14 -0
- sieve/assets/logo-white.png +0 -0
- sieve/assets/logo-white.svg +14 -0
- sieve/assets/logo.png +0 -0
- sieve/assets/logo.svg +20 -0
- sieve/cli.py +286 -0
- sieve/integrations/__init__.py +8 -0
- sieve/integrations/chroma.py +150 -0
- sieve/integrations/langchain.py +150 -0
- sieve/memory.py +165 -0
- sieve/pipeline.py +80 -0
- sieve/policy.py +85 -0
- sieve/schemas.py +54 -0
- sieve/scorer.py +205 -0
- sieve/site/docs.html +2404 -0
- sieve/site/favicon.ico +0 -0
- sieve/site/favicon.png +0 -0
- sieve/site/favicon.svg +15 -0
- sieve/site/index.html +2451 -0
- sieve/site/logo.png +0 -0
- sieve/site/logo.svg +14 -0
- sieve/site/vercel.json +30 -0
- sieve/store.py +521 -0
- sieve/sweep.py +136 -0
- sieve/ui.py +699 -0
- sieve/worker.py +103 -0
- sieve_memory-0.1.0.dist-info/METADATA +493 -0
- sieve_memory-0.1.0.dist-info/RECORD +41 -0
- sieve_memory-0.1.0.dist-info/WHEEL +5 -0
- sieve_memory-0.1.0.dist-info/entry_points.txt +2 -0
- sieve_memory-0.1.0.dist-info/licenses/LICENSE +21 -0
- sieve_memory-0.1.0.dist-info/top_level.txt +1 -0
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
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
|
+
)
|