Python client for Synapsor HTTP/JSON APIs
Project description
Synapsor Python Adapter
The Python adapter is a thin client over synapsor_server HTTP/JSON APIs. It
does not run query planning, memory filtering, capability execution, or policy
logic in Python. Those stay in the C++ DBMS.
Local Usage
from synapsor import Synapsor
db = Synapsor("app.db", auto_start=True)
db.set_session({
"tenant_id": "acme",
"principal": "support_agent_17",
"session_id": "agent_run_1",
})
db.execute("CREATE TABLE messages (id INT, body VARCHAR);")
db.execute("INSERT INTO messages VALUES (1, 'hello');")
rows = db.query("SELECT * FROM messages;")
proposal = db.propose_memory_fact(
scope=("tenant", "acme"),
subject=("preference", "answer_style"),
claim="The operator prefers concise answers.",
source=("turn", "msg_1"),
trust="verified",
approval="approved",
reason="stable preference extracted from chat",
)
db.approve_memory_proposal(proposal["proposal"]["proposal_id"], "operator approved")
memory = db.recall_memory(scope=("tenant", "acme"), subject=("preference", "answer_style"))
db.close()
Hosted Usage
Install from PyPI after the package is published:
python -m pip install synapsor
import os
from synapsor import Synapsor
db = Synapsor("https://dev-api.synapsor.ai", api_key=os.environ["SYNAPSOR_API_KEY"])
db.set_session({
"tenant_id": "acme",
"principal": "app_user_1",
"session_id": "first_hosted_run",
})
print(db.query("SELECT 1;"))
ctx = db.invoke_agent_capability("chat.prepare_llm_context", {"question": "..."})
proposal = db.invoke_agent_capability(
"support.propose_late_fee_waiver",
{"fee_id": "FEE_3001", "reason": "card_update_failure"},
mode="propose_only",
auto_branch=True,
response_envelope=True,
)
Use database-scoped API keys from the Synapsor control panel for hosted projects. The cloud gateway pins those keys to the database runtime branch before forwarding requests to the single-node runtime.
API Surface
execute(sql)andquery(sql)set_session({...})invoke_agent_capability(name, arguments, mode=None, auto_branch=None, response_envelope=None, include_audit_trail=None)list_capabilities(query="...")remember_fact(...)propose_memory_fact(...)approve_memory_proposal(id, reason)reject_memory_proposal(id, reason)list_memory_proposals(...)recall_memory(...)retire_fact(...)andforget_fact(...)check_fact_for_action(...)- branch helpers:
create_branch,use_branch,diff_branch,merge_branch,drop_branch - write lifecycle helpers:
preview_write,approve_write,commit_write,reject_write read_resource(uri)
Errors from Synapsor become SynapsorError with status and payload.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file synapsor-0.1.0.tar.gz.
File metadata
- Download URL: synapsor-0.1.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
512723bb0181f9cb4766a29d3e4e1c6cee25d495f8e90e9338b7fb026c709fb2
|
|
| MD5 |
52f6a2d38b687128bc6dd947afbacbc3
|
|
| BLAKE2b-256 |
b676fccf011a3200b254d25196d9c99b0626958d63ffc3636d4beadca2396c5a
|
File details
Details for the file synapsor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: synapsor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e1e76ae5a9652eaf11e36eb172e238c450003452da99e188dfee0e36c2af304
|
|
| MD5 |
65d4ff3324694dae9aeb1a82833e8936
|
|
| BLAKE2b-256 |
a004196628cdfbe0b58dda0a8c4f30c96499de87bf9e7735f7868f87eaa44027
|