Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

3 Commits

Repository files navigation

AIngle SDK for Python

Python SDK for AIngle, the verifiable memory cortex for AI agents. AIngle Cortex is a semantic graph plus vector memory served over a REST API, so your agents can remember, recall, and reason over durable, queryable knowledge.

Installation

pip install aingle-sdk

Quick Start

fromaingle_sdkimportAIngleClientclient=AIngleClient() # defaults to http://127.0.0.1:19090# Remember a note.saved=client.remember(
"note",
{"text": "Ada prefers dark roast coffee"},
tags=["preference"],
importance=0.7,
)
print("stored id:", saved.id)
# Recall it later by semantic text.hits=client.recall(text="what coffee does Ada like?", limit=5)
forhitinhits:
print(hit.relevance, hit.data)

Configuration

ParameterTypeDefaultDescription
base_urlstrhttp://127.0.0.1:19090AIngle Cortex base URL.
tokenstr or NoneNoneOptional bearer token for a namespace.
timeoutfloat30.0Request timeout in seconds.

Pass a token when a namespace requires authentication:

client=AIngleClient(base_url="https://cortex.example.com", token="my-token")

API Reference

All methods are synchronous and raise AIngleError(status, message) on any non-2xx response.

Health and stats

MethodDescription
health()Service health and component status.
stats()Graph and server statistics.

Memory

MethodDescription
remember(entry_type, data, *, tags, importance, embedding)Store a memory, returns { id }.
recall(*, text, tags, entry_type, min_importance, limit)Recall memories by text or tags.
search(*, embedding, k, min_similarity, entry_type, tags)Vector / semantic search.
memory_stats()Short and long term memory counts.
forget(id)Delete a memory by id.

Triples (semantic graph)

The triple object is an untagged value: str, int, float, bool, or a node reference {"node": "http://example.org/thing"}. Use the node_ref helper to build a node reference.

fromaingle_sdkimportnode_refclient.create_triple("ada", "likes", "coffee")
client.create_triple("ada", "knows", node_ref("http://example.org/grace"))
MethodDescription
create_triple(subject, predicate, object)Insert one triple.
list_triples(*, subject, predicate, object, limit, offset)List triples with filters.
get_triple(id)Fetch a triple by id.
delete_triple(id)Delete a triple by id.

Query

MethodDescription
query(*, subject, predicate, object, limit)Pattern match over triples.
subjects(*, predicate, limit)Distinct subjects, optional filter.
predicates(*, subject, limit)Distinct predicates, optional filter.

Error handling

fromaingle_sdkimportAIngleClient, AIngleErrorclient=AIngleClient()
try:
client.get_triple("does-not-exist")
exceptAIngleErroraserr:
print(err.status, err.message)

Development

# Install dev dependencies.
pip install -e ".[dev]"# Run tests.
pytest
# Type checking.
mypy src
# Linting.
ruff check src

License

Apache-2.0, see LICENSE.

Links

About

The official Python client for AIngle, the memory cortex for AI agents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages