Skip to main content

Python SDK for MaximemSynap context management system

Project description

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

Project details


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.2.5.tar.gz (68.0 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.2.5-py3-none-any.whl (84.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: maximem_synap-0.2.5.tar.gz
  • Upload date:
  • Size: 68.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for maximem_synap-0.2.5.tar.gz
Algorithm Hash digest
SHA256 91ed8ad1db9c42ba59c980a917933d5f1e2b81cb085d9abaa83e3f1d6153fb6e
MD5 0ce161a1fb2b45bdbcd9274a350c6528
BLAKE2b-256 8fa54fc5d96a73e4159f7bca7c984bd33d7a489636df1fd75a538681287e2172

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maximem_synap-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 84.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for maximem_synap-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1ee24504fe6988bcb53de0026beae2b90d73194609b31be4c2027cb6991cae69
MD5 4f218ed7da749c73481cb8e5139b2221
BLAKE2b-256 628119f15238dd28fd1c0a24b8ba925882cfb22dc675342d1b5e426d1f2ea61f

See more details on using hashes here.

Supported by

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