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
  • 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

Release files for maximem-synap 0.4.7

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.4.7
File Size Uploaded
maximem_synap-0.4.7.tar.gz 127.3 kB Details

Built distribution (wheel)

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

Total release size: 271.0 kB

Release files / maximem_synap-0.4.7.tar.gz

Download URL maximem_synap-0.4.7.tar.gz
Size 127.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5dcaaaca2df010150f69036f63e2ac59d38ce56dc0a06394ef64691170fd037c
BLAKE2b-256 checksum
How to use checksums
3e391cb0550f532483982cb5761a2b1e76a92e795287e617f5e66a2ce938b63b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

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

Download URL maximem_synap-0.4.7-py3-none-any.whl
Size 143.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86886d958d6e5b189b3f156adfda55d0eeb8f6f4df398935322af328effecdee
BLAKE2b-256 checksum
How to use checksums
c11dbb609d20bf5d5c0c329ca04e19ddd94422b7f34239b33b0c2a3eb147d61d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

0.5.1

2 release files

0.5.0

2 release files

0.4.12

2 release files

0.4.11

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

This release

0.4.7 This release

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

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