Python SDK for Aionis Memory Graph API
Project description
aionis-sdk
Python SDK for Aionis Memory Graph API.
Install
pip install aionis-sdk
Usage
import os
from aionis_sdk import AionisClient
client = AionisClient(
base_url="http://localhost:3001",
timeout_s=10.0,
api_key=os.getenv("API_KEY"), # optional: X-Api-Key
auth_bearer=os.getenv("AUTH_BEARER"), # optional: Authorization: Bearer <token>
admin_token=os.getenv("ADMIN_TOKEN"), # optional: X-Admin-Token
)
out = client.write(
{
"scope": "default",
"input_text": "python sdk write",
"auto_embed": False,
"nodes": [{"client_id": "py_evt_1", "type": "event", "text_summary": "hello python sdk"}],
"edges": [],
}
)
print(out["status"], out["request_id"], out["data"]["commit_id"])
Typed payloads
0.2.0+ exports TypedDict API payloads from aionis_sdk.types:
from aionis_sdk import AionisClient
from aionis_sdk.types import ToolsFeedbackInput, ToolsSelectInput
client = AionisClient(base_url="http://localhost:3001")
select_payload: ToolsSelectInput = {
"scope": "default",
"run_id": "run_001",
"context": {"intent": "json", "provider": "minimax", "tool": {"name": "curl"}},
"candidates": ["curl", "bash"],
"strict": True,
}
select_out = client.tools_select(select_payload)
decision_id = (select_out.get("data") or {}).get("decision", {}).get("decision_id")
feedback_payload: ToolsFeedbackInput = {
"scope": "default",
"run_id": "run_001",
"decision_id": decision_id,
"outcome": "positive",
"context": {"intent": "json", "provider": "minimax", "tool": {"name": "curl"}},
"candidates": ["curl", "bash"],
"selected_tool": "curl",
}
client.tools_feedback(feedback_payload)
client.tools_run({"scope": "default", "run_id": "run_001"})
Auth Options
api_key: sendsX-Api-Key.auth_bearer: sendsAuthorization: Bearer <token>.admin_token: sendsX-Admin-Token(debug/admin flows).
Covered methods
writerecallrecall_textcontext_assemblefindcreate_sessionwrite_eventlist_session_eventspack_exportpack_importsandbox_create_sessionsandbox_executesandbox_run_getsandbox_run_logssandbox_run_artifactsandbox_run_cancelrules_evaluatetools_selecttools_decisiontools_runtools_feedbackhealthget_capability_contract
Admin/control methods (require admin_token):
control_upsert_tenant,control_list_tenants,control_upsert_projectcontrol_create_api_key,control_list_api_keys,control_list_stale_api_keys,control_revoke_api_key,control_rotate_api_keycontrol_create_alert_route,control_list_alert_routes,control_update_alert_route_status,control_list_alert_deliveriescontrol_enqueue_incident_publish_job,control_list_incident_publish_jobs,control_replay_incident_publish_jobscontrol_upsert_tenant_quota,control_get_tenant_quota,control_delete_tenant_quotacontrol_upsert_sandbox_budget,control_get_sandbox_budget,control_delete_sandbox_budget,control_list_sandbox_budgetscontrol_list_audit_events,control_get_tenant_dashboard,control_get_tenant_diagnosticscontrol_get_tenant_incident_publish_rollup,control_get_tenant_incident_publish_slo,control_get_tenant_timeseries,control_get_tenant_key_usage
Error model
AionisApiError: API returned non-2xx response.AionisNetworkError: request timeout/network failure.
Capability-aware helpers:
is_backend_capability_unsupported_error(err)parse_backend_capability_error_details(err.details)is_shadow_dual_write_strict_failure_error(err)parse_shadow_dual_write_strict_failure_details(err.details)
from aionis_sdk import AionisApiError, is_backend_capability_unsupported_error
try:
client.pack_export({"scope": "default"})
except Exception as err:
if is_backend_capability_unsupported_error(err):
print(err.details.get("capability"), err.details.get("failure_mode"))
elif isinstance(err, AionisApiError):
print(err.code, str(err))
Smoke
set -a; source .env; set +a
npm run sdk:py:smoke
Build check (repo local)
npm run sdk:py:compile
npm run sdk:py:release-check
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aionis_sdk-0.2.4.tar.gz
(13.5 kB
view details)
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 aionis_sdk-0.2.4.tar.gz.
File metadata
- Download URL: aionis_sdk-0.2.4.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc312fce1704dcc80e913da64a24e083126502674737575f5a2117c815c5dff8
|
|
| MD5 |
9da5cd9c3c8594a6382d59b62ef55bbd
|
|
| BLAKE2b-256 |
22017c8fe03203c79cf6bcaff891d14b613951423a7bfa54498ecb4b41f3b625
|
File details
Details for the file aionis_sdk-0.2.4-py3-none-any.whl.
File metadata
- Download URL: aionis_sdk-0.2.4-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
357364551df7293ec74b79fc97af62a4712edce4e532f785c6f3469d967a126f
|
|
| MD5 |
034eede6eda533bd6c277bb5fb9a101c
|
|
| BLAKE2b-256 |
6d1bace0fcb6be0ac69c1359839b1e76fb82c9eb11bd83a0eec28798ef8d1dbf
|