Skip to content

About

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

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

AIngle SDK for Swift

Official Swift SDK for AIngle, the verifiable memory cortex for AI agents.

AIngle gives your agents a durable, queryable memory: a semantic graph of triples plus vector-backed recall, served over a simple REST API. This SDK is a thin, typed async client over that API with no third-party dependencies.

Installation

Swift Package Manager

Add to your Package.swift:

dependencies: [
    .package(url: "https://github.com/ApiliumCode/aingle-sdk-swift.git", from: "0.2.0")
]

Then add the product to your target's dependencies:

.target(
    name: "YourTarget",
    dependencies: [
        .product(name: "AIngleSDK", package: "aingle-sdk-swift")
    ]
)

Or in Xcode: File, Add Package Dependencies, then enter the URL:

https://github.com/ApiliumCode/aingle-sdk-swift.git

Quick Start

Store a memory with remember, then bring it back with recall.

import AIngleSDK

let client = AIngleClient()

// Store a memory entry.
let id = try await client.remember(
    entryType: "note",
    data: ["text": "Ada prefers dark mode and concise answers."],
    tags: ["preference", "ada"],
    importance: 0.8
)
print("Stored memory:", id)

// Recall it later by text, tags, or type.
let hits = try await client.recall(text: "dark mode", limit: 5)
for hit in hits {
    print(hit.id, hit.relevance, hit.data)
}

Configuration

The client defaults to a local Cortex server. Point it elsewhere and add a bearer token when your namespace is protected.

let client = AIngleClient(
    baseURL: URL(string: "http://127.0.0.1:19090")!,
    token: "your-namespace-token",
    timeout: 30
)

Working with the semantic graph

Triples are subject, predicate, object. The object is an untagged value: a string, integer, double, boolean, or a node reference (an IRI). The SDK models it as AIngleValue.

// Create triples.
try await client.createTriple(subject: "ada", predicate: "role", object: "engineer")
try await client.createTriple(subject: "ada", predicate: "age", object: 34)
try await client.createTriple(
    subject: "ada",
    predicate: "worksAt",
    object: .node("http://example.org/apilium")
)

// Query by pattern.
let result = try await client.query(subject: "ada")
for triple in result.matches {
    print(triple.predicate, triple.object)
}

// List distinct predicates for a subject.
let predicates = try await client.predicates(subject: "ada")
print(predicates.predicates)

Health and stats

let health = try await client.health()
print(health.status, health.components.graph.status)

let stats = try await client.stats()
print("triples:", stats.graph.tripleCount)
print("uptime:", stats.server.uptimeSeconds)

API Reference

Health and stats

Method Description
health() Server health and per-component status.
stats() Graph and server statistics.

Memory

Method Description
remember(entryType:data:tags:importance:embedding:) Store a memory entry, returns its id.
recall(text:tags:entryType:minImportance:limit:) Recall entries by text, tags, type, importance.
search(embedding:k:minSimilarity:entryType:tags:) Vector search using a precomputed embedding.
memoryStats() Short and long term memory statistics.
forget(_:) Delete a memory entry by id.

Triples

Method Description
createTriple(subject:predicate:object:) Create a triple.
createTriples(_:) Insert multiple triples in one call.
listTriples(subject:predicate:object:limit:offset:) List triples with optional filters.
getTriple(_:) Fetch a triple by id.
deleteTriple(_:) Delete a triple by id.

Query

Method Description
query(subject:predicate:object:limit:) Match triples against a pattern.
subjects(predicate:limit:) Distinct subjects, optionally scoped to a predicate.
predicates(subject:limit:) Distinct predicates, optionally scoped to a subject.

All methods are async and throws. Failures surface as AIngleError, which carries an optional HTTP status and a message.

Platform Support

Platform Minimum Version
iOS 15.0
macOS 12.0
tvOS 15.0
watchOS 8.0

Development

# Build
swift build

# Run tests
swift test

License

Apache-2.0, see LICENSE.

Links

About

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

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages