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
Release files for maximem-synap 0.4.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| maximem_synap-0.4.11.tar.gz | 138.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| maximem_synap-0.4.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 295.2 kB
Release files / maximem_synap-0.4.11.tar.gz
| Download URL | maximem_synap-0.4.11.tar.gz |
|---|---|
| Size | 138.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
49b9b42c628f84ba5a6765f692bcaa8fe067e47d962d0df2980aa77adfebf3f0
|
|
BLAKE2b-256 checksum How to use checksums |
83d847c151c4f24aec21fb4c1140ff2893a9a17ba48fa8cb3b491ebf28ca20ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Release files / maximem_synap-0.4.11-py3-none-any.whl
| Download URL | maximem_synap-0.4.11-py3-none-any.whl |
|---|---|
| Size | 156.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cefea48262c5e44cd8728c422a45c5b9b16a78f6a9162dd98783719733f842a0
|
|
BLAKE2b-256 checksum How to use checksums |
a900b72c1f0119eb7a56998a5a3098bf073b13b6e92a58fa83996fd5f2425aef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|