HTTP client for TrustMem server
Project description
trustmem-client
HTTP client for TrustMem server.
Lightweight client with only httpx as a dependency — no trustmem package needed.
Install
pip install trustmem-client
Quick Start
from trustmem_client import TrustMemClient
# Auto-load from environment variables (TRUSTMEM_BASE_URL, TRUSTMEM_API_KEY)
client = TrustMemClient()
# Or specify explicitly
client = TrustMemClient(base_url="http://localhost:8080", api_key="tm-xxx")
# Add memories from conversation messages
client.add(
[{"role": "user", "content": "Alex likes sushi"}],
user_id="alex",
)
# Shared knowledge (no specific user)
client.add(
[{"role": "user", "content": "Company policy: 20 vacation days"}],
visibility="organization",
)
# Search (returns user memories + shared knowledge)
result = client.search("food preferences", user_id="alex")
print(result) # {"results": [...], "relations": [...]}
# List all memories for a user
all_memories = client.get_all(user_id="alex")
# Delete
client.delete(memory_id)
# Clean up
client.close()
Configuration
| Environment Variable | Default | Description |
|---|---|---|
TRUSTMEM_BASE_URL |
http://localhost:8080 |
Server URL |
TRUSTMEM_API_KEY |
— | API key for Bearer authentication |
Environment variables can be set in a .env file (requires pip install trustmem-client[dotenv]).
Constructor arguments take priority over environment variables.
Scoping
All data methods require either user_id or visibility="organization":
client.add(data, user_id="alex") # User-specific memory
client.add(data, visibility="organization") # Shared knowledge
client.add(data) # Error
When searching with user_id, both user-specific and shared memories are returned.
API
| Method | Scope | Description |
|---|---|---|
add(data, *, user_id, visibility) |
user_id or visibility |
Extract and store memories from conversation messages |
search(query, *, user_id, visibility) |
user_id or visibility |
Hybrid search (vector + keyword) with ZTM trust filtering |
search_raw(query, *, user_id, visibility) |
user_id or visibility |
Pure cosine similarity search (no TrustMem ranking) |
get_all(*, user_id, visibility) |
user_id or visibility |
Get all memories and relations |
delete(memory_id) |
— | Delete a memory by ID |
close() |
— | Close the HTTP connection |
TrustMemClient supports the context manager protocol (with statement).
License
BSL-1.1 — See LICENSE for full terms.
Project details
Release history Release notifications | RSS feed
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 trustmem_client-0.9.5.tar.gz.
File metadata
- Download URL: trustmem_client-0.9.5.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
458c769d3c97dd5d80b2bcce998674cbf5e213a1a1ecbcca09e703ed12436f13
|
|
| MD5 |
5dfb1cf9799fe69a03943d5d3f31e8b3
|
|
| BLAKE2b-256 |
30b102d0bdacb38b1423f1bb7065cd0afa5566bf717b277c90aec538aa0af654
|
File details
Details for the file trustmem_client-0.9.5-py3-none-any.whl.
File metadata
- Download URL: trustmem_client-0.9.5-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b50b17caa279aa488a59f26d8e721b5ea62e0062165cbe0e7c946fad3e25ce6c
|
|
| MD5 |
73a53ed89fcf5729a2ac08e412f9cb51
|
|
| BLAKE2b-256 |
d714e1e7af6dc89556203834ba0e672d9d70d3bd708cba5958d127f00d5a9516
|