Skip to main content

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 information
  • ContextType.PREFERENCES: User preferences
  • ContextType.EPISODES: Conversation episodes
  • ContextType.EMOTIONS: Emotional context
  • ContextType.TEMPORAL: Time-based context (sent as temporal_events)
  • ContextType.ALL: All context types

Compaction Levels

  • CompactionLevel.AGGRESSIVE: Maximum compression
  • CompactionLevel.BALANCED: Balanced approach
  • CompactionLevel.CONSERVATIVE: Minimal compression
  • CompactionLevel.ADAPTIVE: Adaptive based on context

License

MIT

Metadata

Release files for maximem-synap 0.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maximem-synap 0.7.2
File Size Uploaded Provenance Actions
maximem_synap-0.7.2.tar.gz 289.2 kB Without provenance Details for maximem_synap-0.7.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for maximem-synap 0.7.2
File Interpreter ABI Platform Actions
maximem_synap-0.7.2-py3-none-any.whl Python 3 none any Details for maximem_synap-0.7.2-py3-none-any.whl

Total release size: 555.4 kB

Release files / maximem_synap-0.7.2.tar.gz

Download URL maximem_synap-0.7.2.tar.gz
Size 289.2 kB
Tags Source
SHA-256 checksum
How to use checksums
64fcd88fe0a4d4da24666afcb83b57c81604859d81e40a0f8e5ec1a012ca89fe
BLAKE2b-256 checksum
How to use checksums
a84385cd44a4c7b7167f34a53d96159399e8d0757aeffaf713971c3101a46e48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / maximem_synap-0.7.2-py3-none-any.whl

Download URL maximem_synap-0.7.2-py3-none-any.whl
Size 266.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de6610c352b3c68737fb69d8db9393466438c2d35435dac2b58e0b9e08702f48
BLAKE2b-256 checksum
How to use checksums
65ff9c1548792f767b2237688d29aaded15d61de5b1018c23bd328f6e1f3a4a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Security for maximem-synap 0.7.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page