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

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.1.tar.gz (122.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maximem_synap-0.4.1-py3-none-any.whl (143.7 kB view details)

Uploaded Python 3

File details

Details for the file maximem_synap-0.4.1.tar.gz.

File metadata

  • Download URL: maximem_synap-0.4.1.tar.gz
  • Upload date:
  • Size: 122.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for maximem_synap-0.4.1.tar.gz
Algorithm Hash digest
SHA256 2b15affeec562e861fc9d564e20ff8b267755b5d2e28e34f62aec47905447437
MD5 beaa30604f4827436e53d0edb8b71c16
BLAKE2b-256 9bc69c4be67ad83d74bad351c8df3425afbdff575612148280b704122a524d8b

See more details on using hashes here.

File details

Details for the file maximem_synap-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: maximem_synap-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 143.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for maximem_synap-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93f70a96fdfa12349d1220c1df836d1aa35e964626c7ceaffd1a093a938fc7ff
MD5 a1ff79fbffa7b5c80fe4789658c193a1
BLAKE2b-256 ace45c7b2a79d7919dc5b9e000e8cf91534288aab09587695cca35de3217877e

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.5

2 files

0.4.4

2 files

0.4.3

2 files

0.4.2

2 files

This release

0.4.1 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page