Skip to main content

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)

Auth Options

  1. api_key: sends X-Api-Key.
  2. auth_bearer: sends Authorization: Bearer <token>.
  3. admin_token: sends X-Admin-Token (debug/admin flows).

Covered methods

  1. write
  2. recall
  3. recall_text
  4. context_assemble
  5. find
  6. create_session
  7. write_event
  8. list_session_events
  9. pack_export
  10. pack_import
  11. rules_evaluate
  12. tools_select
  13. tools_decision
  14. tools_feedback
  15. health
  16. get_capability_contract

Admin/control methods (require admin_token):

  1. control_upsert_tenant, control_list_tenants, control_upsert_project
  2. control_create_api_key, control_list_api_keys, control_list_stale_api_keys, control_revoke_api_key, control_rotate_api_key
  3. control_create_alert_route, control_list_alert_routes, control_update_alert_route_status, control_list_alert_deliveries
  4. control_enqueue_incident_publish_job, control_list_incident_publish_jobs, control_replay_incident_publish_jobs
  5. control_upsert_tenant_quota, control_get_tenant_quota, control_delete_tenant_quota
  6. control_list_audit_events, control_get_tenant_dashboard, control_get_tenant_diagnostics
  7. control_get_tenant_incident_publish_rollup, control_get_tenant_incident_publish_slo, control_get_tenant_timeseries, control_get_tenant_key_usage

Error model

  1. AionisApiError: API returned non-2xx response.
  2. AionisNetworkError: request timeout/network failure.

Capability-aware helpers:

  1. is_backend_capability_unsupported_error(err)
  2. parse_backend_capability_error_details(err.details)
  3. is_shadow_dual_write_strict_failure_error(err)
  4. 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


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.3.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

aionis_sdk-0.2.3-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file aionis_sdk-0.2.3.tar.gz.

File metadata

  • Download URL: aionis_sdk-0.2.3.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for aionis_sdk-0.2.3.tar.gz
Algorithm Hash digest
SHA256 5c9800d62dabe62ad3b07f606505bfb1f081d97f2353f0d4a60de9b0ac4e2bf7
MD5 5e2019600b51b5a9ccb1eef538c8d77c
BLAKE2b-256 e277001ac6eeb5f3d0a7af2a3e6e3d3be8e18ff244cdb4a7bfac670ace13fd70

See more details on using hashes here.

File details

Details for the file aionis_sdk-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: aionis_sdk-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for aionis_sdk-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e2b6acc8d9930903df6056a78c495675a886f6a7348312ef93cba68654fac515
MD5 51c6d017fe91acb4a5daa6878e24a308
BLAKE2b-256 0ed68a56ae7c9c353399bbbe5e374428768cc10e4e62de34fedbbcbf114d73c5

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