Skip to main content

Official Python SDK for SynapCores AI-Native Database

Project description

SynapCores Python SDK

Official Python SDK for SynapCores - The AI-Native Database Management System.

0.2.0 — gateway v1.5.0-ce alignment. This release rewires every module against the v1.5.0-ce route surface. AutoML moved from /ai/* to /automl/*, vector ops collapsed onto /vector-algebra/operation, WebSocket auth now uses ticket exchange, API keys are sent via the X-API-Key header (and accept the new ak_* prefix in addition to the legacy aidb_*), and we ship new top-level modules: graph, nl2sql, filesystem, chat, multimodal, system, transactions, mcp, recipes, and schema.

What's new in 0.2.0

from synapcores import SynapCores

client = SynapCores(host="localhost", port=8080, api_key="ak_prod_xxx...")

# 1. Cypher-style graph traversal
friends = client.graph.cypher(
    "MATCH (u:User {id:$id})-[:FRIEND]->(f) RETURN f",
    {"id": "u-123"},
)

# 2. Natural language → SQL (with optional execution)
ans = client.nl2sql.ask(
    "top 10 customers by revenue this quarter",
    execute=True,
)
print(ans["sql"], ans.get("rows"))

# 3. AI chat sessions with streaming
session = client.chat.sessions.create(model="gpt-4o")
for chunk in client.chat.stream(session["id"], "Summarize today's alerts"):
    if chunk.get("delta"):
        print(chunk["delta"], end="", flush=True)

# 4. Filesystem-backed RAG collections with progress
fs = client.filesystem.collections.create(name="docs", path="/data/docs", watch=True)
for evt in client.filesystem.collections.subscribe_progress(fs["id"]):
    print(evt.get("status"), evt.get("progress"), evt.get("filename"))

# 5. Server-side transactions with savepoints
with client.transactions.begin(isolation_level="SERIALIZABLE") as tx:
    tx.execute("UPDATE accounts SET balance = balance - $1 WHERE id = $2", [100, "a"])
    tx.savepoint("mid")
    tx.execute("UPDATE accounts SET balance = balance + $1 WHERE id = $2", [100, "b"])
    # commit() runs implicitly on clean exit; rollback() on exception.

Other new surfaces:

  • client.multimodal.{similarity,search,join,embed} for cross-modal retrieval.
  • client.system.vision.{get,set,delete,test} for the admin vision config.
  • client.mcp.{invoke,batch,info} for the Model Context Protocol gateway.
  • client.recipes.list_categories()/list_templates()/execute_template()/list_executions().
  • client.schema.list_databases()/preview_table().

Breaking changes vs 0.1.0

  • embed() routes to /ai/embeddings (single) or /ai/embeddings/batch.
  • automl.* paths moved from /ai/* to /automl/*.
  • All vector math goes through POST /vector-algebra/operation with an op discriminator.
  • KNN/range/hybrid search routes to /vectors/collections/:name/search with a mode field.
  • API keys are sent as the X-API-Key header (was previously Authorization: Bearer).
  • WebSocket subscriptions now use ticket exchange via POST /v1/ws/ticket and connect to /ws?token=....
  • nlp.analyze() is implemented client-side as parallel calls to /ai/sentiment, /ai/entities, and /ai/summarize since /ai/analyze was removed.
  • The client.sql(query, params=...) payload now matches POST /v1/query/execute (positional parameters); params is still accepted as a dict for backwards compatibility.

Features

  • AI-Native Operations: Built-in support for embeddings, vector search, and semantic analysis
  • Document & Vector Storage: Seamlessly work with both structured and unstructured data
  • SQL with AI Extensions: Use familiar SQL syntax enhanced with AI operations
  • Real-time Subscriptions: WebSocket support for live data updates
  • AutoML Integration: Automated machine learning model training and deployment
  • Type-Safe: Full type hints and Pydantic models for better IDE support

Installation

pip install synapcores

Quick Start

from synapcores import SynapCores

# Initialize client with API key authentication
# API keys can be created from your AIDB dashboard at Settings > API Keys
# Note: API keys must start with 'aidb_' prefix
client = SynapCores(
    host="localhost",
    port=8080,
    api_key="aidb_sk_your_api_key_here"  # Replace with your actual API key
)

# Create a collection
collection = client.create_collection(
    name="products",
    schema={
        "name": "string",
        "description": "string",
        "price": "float",
        "embedding": "vector[384]"
    }
)

# Insert documents
collection.insert([
    {
        "name": "Laptop",
        "description": "High-performance laptop for developers",
        "price": 1299.99
    },
    {
        "name": "Mouse",
        "description": "Ergonomic wireless mouse",
        "price": 49.99
    }
])

# Semantic search
results = collection.search(
    query="computer accessories",
    top_k=5
)

# SQL with AI extensions
df = client.sql("""
    SELECT name, price, 
           similarity(embedding, embed('perfect for coding')) as relevance
    FROM products
    WHERE price < 1500
    ORDER BY relevance DESC
    LIMIT 10
""")

# Real-time subscriptions
async def handle_update(change):
    print(f"Document {change.op}: {change.document}")

subscription = await collection.subscribe(
    filter={"price": {"$lt": 100}},
    on_change=handle_update
)

Advanced Features

Vector Operations

# Generate embeddings
embedding = client.embed("High-quality mechanical keyboard")

# Vector similarity search
similar_products = collection.vector_search(
    vector=embedding,
    top_k=10,
    filter={"price": {"$between": [50, 200]}}
)

AutoML

# Train a model
model = client.automl.train(
    collection="sales_data",
    target="revenue",
    features=["product_category", "season", "price"],
    task="regression"
)

# Make predictions
predictions = model.predict({
    "product_category": "electronics",
    "season": "holiday",
    "price": 299.99
})

NLP Analysis

# Analyze text
analysis = client.nlp.analyze(
    text="This product exceeded my expectations. Highly recommend!",
    tasks=["sentiment", "entities", "summary"]
)

print(f"Sentiment: {analysis.sentiment.label} ({analysis.sentiment.score})")
print(f"Entities: {[e.text for e in analysis.entities]}")

Documentation

For detailed documentation, visit https://synapcores.com/developers

License

MIT License - see LICENSE file for details.

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

synapcores-0.2.0.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

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

synapcores-0.2.0-py3-none-any.whl (44.8 kB view details)

Uploaded Python 3

File details

Details for the file synapcores-0.2.0.tar.gz.

File metadata

  • Download URL: synapcores-0.2.0.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for synapcores-0.2.0.tar.gz
Algorithm Hash digest
SHA256 57a3bb01ae18838453cafb2e3e2335742d0eb5a443b7057a4553e4a82c34c69e
MD5 bb34496501f9826037cecf675fbf4094
BLAKE2b-256 ceb2461e8accac39509855af782e3e65e685661eaf21951f1251f7a15b4a6c4d

See more details on using hashes here.

File details

Details for the file synapcores-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: synapcores-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 44.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for synapcores-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdc8708aa4a08773c6379c7deddf21272548c37c6b62d59fd9f126cf5191646f
MD5 1460f9d15b838c0365c51ca84f61dccf
BLAKE2b-256 358162ade8d2b83a9eeb702752e4cb00966a3244fc8e32519a317853e828f4f7

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