Skip to main content

Synaptic Core foundation and persistence layer for graph-backed memory.

Project description

synaptic-core

synaptic-core v0.3 ships a clean canonical API for graph memory:

  • Clients: AsyncSynaptic and Synaptic
  • Core methods: remember, recall, set, get, find, connect, related
  • Session-first helpers: client.session("...")
  • Structured errors: SynapticError { code, message, hint }

Install

pip install synaptic-core

Happy Path (Async, Session-First)

import asyncio

from synaptic_core import AsyncSynaptic, SynapticError
from synaptic_core.types import OutcomeSignalType


def embed(text: str) -> list[float]:
    normalized = text.lower().strip()
    return [
        float(len(normalized.split())),
        float(len(normalized)) / 100.0,
        float(sum(ord(ch) for ch in normalized) % 257) / 257.0,
    ]


async def main() -> None:
    client = AsyncSynaptic(db_path="synaptic.db", embedding_fn=embed)
    session = client.session("chat-42")

    await session.remember("Customer asked for monthly usage CSV export")
    recall = await session.recall("How do I export monthly usage as CSV?", top_k=5)

    if recall.nodes:
        await session.feedback(
            recall.query_id,
            outcome=OutcomeSignalType.EXPLICIT_POSITIVE,
            provider="app",
        )

    print("nodes", [str(node.id) for node in recall.nodes])
    print("stats", await client.stats())


try:
    asyncio.run(main())
except SynapticError as exc:
    print(exc.as_dict())

Canonical API

  • remember(content, *, session_id="default", memory_type=None, external_id=None, source_type=None, metadata=None) -> Node
  • recall(query, *, session_id="default", top_k=None) -> RetrievalResult
  • feedback(query_id, outcome, *, session_id=None, agent_response=None, user_next_message=None, dwell_time_ms=None, active_nodes=None, corrected_nodes=None, provider="unknown") -> CompositeOutcome
  • set(key, value, *, namespace=None, metadata=None, ttl=None) -> None
  • get(key, *, namespace=None) -> Any | None
  • find(query, *, namespace=None, limit=10, filters=None) -> list[dict]
  • connect(node_a_id, node_b_id, *, weight=0.3, connection_type="excitatory", formation_trigger="explicit", is_cross_tier=None) -> dict
  • related(node_id, *, limit=None) -> list[dict]
  • stats() -> dict
  • graph_status() -> dict
  • sessions_recent(limit=20) -> list[dict]
  • queries_recent(session_id=None, limit=20) -> list[dict]
  • outcomes_recent(session_id=None, limit=20) -> list[dict]

Session-First Helpers

  • client.session(session_id).remember(...)
  • client.session(session_id).recall(...)
  • client.session(session_id).feedback(...)
  • client.session(session_id).summary()
  • client.session(session_id).queries_recent(limit=20)
  • client.session(session_id).outcomes_recent(limit=20)

CLI

synaptic doctor --db-path synaptic.db
synaptic stats --db-path synaptic.db --json
synaptic graph status --db-path synaptic.db --json
synaptic sessions recent --db-path synaptic.db --limit 20 --json
synaptic queries recent --db-path synaptic.db --session-id chat-42 --limit 20 --json
synaptic migrate-api /path/to/codebase --write

Migration

Strict migration steps and breaking changes are documented in:

  • docs/migration-v0.2-to-v0.3.md

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

synaptic_core-0.3.0.tar.gz (84.2 kB view details)

Uploaded Source

Built Distribution

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

synaptic_core-0.3.0-py3-none-any.whl (92.0 kB view details)

Uploaded Python 3

File details

Details for the file synaptic_core-0.3.0.tar.gz.

File metadata

  • Download URL: synaptic_core-0.3.0.tar.gz
  • Upload date:
  • Size: 84.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for synaptic_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 49ab5997d3d5c647dedc0b33fbe84ba7969a6e09678f3a53be524fea767690d7
MD5 c1c3e2e26f8819c89e43ad17ee6fa0db
BLAKE2b-256 3f4935ad74bd9c3a82db30babbda46a3890345fe8d4d5d4afa5c895f3a01be8a

See more details on using hashes here.

File details

Details for the file synaptic_core-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: synaptic_core-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 92.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for synaptic_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3149541646ab62d3ef22c4a742b97369380a5aa64f9cb2bf4aab9cb146f7ba2e
MD5 5fd25afa0a3aa03b6b4d831dd47c70c9
BLAKE2b-256 c91c888017b2c62622626f427f2c52e144e3ae9886e12dafa23ec8b51d6023cb

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