The missing debugger for vector retrieval
Project description
agent-memory-inspector
The missing debugger for vector retrieval. See scores in under 60 seconds.
Install
pip install agent-memory-inspector
Or in development:
pip install -e ".[dev]"
Quickstart
from memory_inspector import Inspector, ScoredResult
def my_retriever(query: str, top_k: int = 5) -> list[ScoredResult]:
# Replace with your real retrieval logic
return [
ScoredResult(content="Our pricing starts at $10/mo", score=0.92),
ScoredResult(content="Enterprise pricing available", score=0.87),
ScoredResult(content="Contact sales for details", score=0.45),
]
inspector = Inspector(my_retriever)
result = inspector.query("pricing policy")
print(result)
Output:
RetrievalRecord(
query='pricing policy' | latency=0.1ms | 3 results
[0] score=0.920 Our pricing starts at $10/mo
[1] score=0.870 Enterprise pricing available
[2] score=0.450 Contact sales for details
)
API
Inspector(retriever, *, config=None, store=None, random_fn=random.random)
retriever: any callable with signature(query: str, top_k: int) -> list[ScoredResult]config:InspectorConfig(optional)store:InMemoryStoreorSQLiteStore(optional, defaults to in-memory)random_fn: override for sampling control (useful in tests)
inspector.query(query, top_k=5, **kwargs) -> RetrievalRecord
Calls the retriever, records latency, stores the trace (subject to sample_rate), returns the record.
inspector.last() -> RetrievalRecord | None
The most recent record. Always set, regardless of sampling.
inspector.history(limit=20) -> list[RetrievalRecord]
Recent records from the store, most recent first.
Config
from memory_inspector import InspectorConfig, Mode
config = InspectorConfig(
mode=Mode.DEV, # DEV or PROD
sample_rate=1.0, # 1.0 = log all, 0.1 = 10%
max_records=1000, # ring buffer cap (InMemoryStore)
)
inspector = Inspector(my_retriever, config=config)
Persistent storage
from memory_inspector import Inspector, SQLiteStore
store = SQLiteStore(".memory_inspector/traces.db")
inspector = Inspector(my_retriever, store=store)
Retriever contract
Your retriever must:
- Accept
(query: str, top_k: int)as positional/keyword arguments - Return
list[ScoredResult] - Each
ScoredResultmust have a numericscore
If rank is omitted (None), it is auto-assigned from list order.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_memory_inspector-0.1.0.tar.gz.
File metadata
- Download URL: agent_memory_inspector-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a245e66e346e93d8ea9ed22f1e8ef55ceaa6810d0efc0cd3540854fac96ca31
|
|
| MD5 |
eb31ccd99c9c564f1b85de64dde1c337
|
|
| BLAKE2b-256 |
023e3a0c5239c8388d15015ebd97c76433bd240f9faf708df964c5b25faf6f5e
|
File details
Details for the file agent_memory_inspector-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_memory_inspector-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaa3991166c31380cdd549ab2bf59d74c8d56dd8254a49767563907374200fff
|
|
| MD5 |
bdabfa9e5ccbfd7bacb1490d2f9feea2
|
|
| BLAKE2b-256 |
2445b52e6825706c9f494ab5511e4dec7311ef5329ad3b28bf4642aaf11561d9
|