MaximemSynap Python SDK
Python client library for the MaximemSynap context management system.
Installation
pip install maximem-synap
Quick Start
from maximem_synap import MaximemSynapSDK, ContextType, CompactionLevel
# Initialize SDK (reads SYNAP_API_KEY from your environment)
sdk = MaximemSynapSDK()
# Fetch conversation context
context = sdk.conversation.fetch(
conversation_id="conv-123",
search_query="user preferences",
max_results=10,
types=[ContextType.FACTS, ContextType.PREFERENCES]
)
# Access context items
for item in context.items:
print(f"{item.context_type}: {item.content}")
# Compact conversation context
compacted = sdk.conversation.compact(
conversation_id="conv-123",
compaction_level=CompactionLevel.BALANCED
)
# Fetch user context
user_context = sdk.user.fetch(
user_id="user-456",
conversation_id="conv-123", # Optional
max_results=20
)
# Listen for real-time updates
sdk.instance.listen()
# ... your application logic ...
sdk.instance.stop()
# Cleanup
sdk.shutdown()
Configuration
from maximem_synap import CacheConfig, TimeoutConfig
# Configure caching
cache_config = CacheConfig(
enabled=True,
ttl_seconds=300,
max_entries=1000
)
# Configure timeouts
timeout_config = TimeoutConfig(
connect_timeout_ms=5000,
read_timeout_ms=30000,
total_timeout_ms=60000
)
# Apply configuration
sdk.configure(
cache=cache_config,
log_level="DEBUG",
timeouts=timeout_config
)
Environment Variables
SYNAP_API_KEY: Your Synap API key
Context Controllers
Conversation Context
# Fetch conversation context
context = sdk.conversation.fetch(
conversation_id="conv-123",
search_query="optional search",
max_results=10,
types=[ContextType.FACTS]
)
# Compact conversation context
compacted = sdk.conversation.compact(
conversation_id="conv-123",
compaction_level=CompactionLevel.ADAPTIVE
)
User Context
context = sdk.user.fetch(
user_id="user-456",
conversation_id="conv-123", # Optional
types=[ContextType.PREFERENCES, ContextType.EMOTIONS]
)
Customer Context
context = sdk.customer.fetch(
customer_id="cust-789",
conversation_id="conv-123" # Optional
)
Client Context
context = sdk.client.fetch(
client_id="client-abc",
conversation_id="conv-123" # Optional
)
Error Handling
from maximem_synap import (
SDKError,
AgentUnavailableError,
ContextNotFoundError,
AuthenticationError
)
try:
context = sdk.conversation.fetch(conversation_id="conv-123")
except AgentUnavailableError as e:
# Retryable error
print(f"Agent unavailable: {e}")
except ContextNotFoundError as e:
# Non-retryable error
print(f"Context not found: {e}")
except AuthenticationError as e:
# Authentication failed
print(f"Auth error: {e}")
except SDKError as e:
# Base exception
print(f"SDK error: {e}, retryable: {e.retryable}")
Context Types
ContextType.FACTS: Factual informationContextType.PREFERENCES: User preferencesContextType.EPISODES: Conversation episodesContextType.EMOTIONS: Emotional contextContextType.TEMPORAL: Time-based contextContextType.ALL: All context types
Compaction Levels
CompactionLevel.AGGRESSIVE: Maximum compressionCompactionLevel.BALANCED: Balanced approachCompactionLevel.CONSERVATIVE: Minimal compressionCompactionLevel.ADAPTIVE: Adaptive based on context
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
maximem_synap-0.4.2.tar.gz
(116.4 kB
view details)
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
maximem_synap-0.4.2-py3-none-any.whl
(134.7 kB
view details)
File details
Details for the file maximem_synap-0.4.2.tar.gz.
File metadata
- Download URL: maximem_synap-0.4.2.tar.gz
- Upload date:
- Size: 116.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bbde9c0382a7788736cd3a2f405a470e3ac6d9fa8e492a4f8c127c7963efa63
|
|
| MD5 |
e37b9159853c53e7dee168df3155d776
|
|
| BLAKE2b-256 |
fdc971f9419ef1150c4fe3ff26673fca25e62e640c7d0f4387596d8a5d7101ef
|
File details
Details for the file maximem_synap-0.4.2-py3-none-any.whl.
File metadata
- Download URL: maximem_synap-0.4.2-py3-none-any.whl
- Upload date:
- Size: 134.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72ca22cfbf2ba948bc02912d674d603326f11c3a7b8359aee63a77d98e920cb7
|
|
| MD5 |
125485d11c04cd410fa5bc82d68a66ac
|
|
| BLAKE2b-256 |
c62c01b8b470080983d66717b197326de06d4c8cda91f87b2a360a5dd2ea7380
|