Python client for Iranti memory infrastructure
Project description
Iranti Python Client
Python client for the Iranti REST API.
Installation
pip install iranti
For local development from this repository:
cd clients/python
pip install -e .
Setup
Start the Iranti API server first:
# In your Iranti directory
npm run api
Usage
from iranti import IrantiClient
client = IrantiClient(
base_url="http://localhost:3001",
api_key="replace-with-real-iranti-key"
)
# Or use environment variables
# IRANTI_URL=http://localhost:3001
# IRANTI_API_KEY=replace-with-real-iranti-key
client = IrantiClient()
# Check server is running
print(client.health())
# Write a fact
result = client.write(
entity="researcher/jane_smith",
key="affiliation",
value={"institution": "MIT"},
summary="Affiliated with MIT",
confidence=85,
source="OpenAlex",
agent="my_agent"
)
print(result.action) # created / updated / rejected / escalated
# Ingest raw text
result = client.ingest(
entity="researcher/jane_smith",
content="Dr. Jane Smith has 24 publications and is at MIT CSAIL.",
source="OpenAlex",
confidence=80,
agent="my_agent"
)
print(
f"Extracted: {result.extracted_candidates}, "
f"Written: {result.written}, "
f"Skipped malformed: {result.skipped_malformed}"
)
# Get working memory before a task
brief = client.handshake(
agent="my_agent",
task="Research publication history",
recent_messages=["Starting research..."]
)
print(brief.inferred_task_type)
# Per-turn memory decision (inject only when needed)
turn = client.attend(
agent_id="my_agent",
latest_message="What is my favorite snack?",
current_context="User: What is my favorite snack?\nAssistant:",
entity_hints=["user/main"]
)
print(turn["shouldInject"], turn["reason"])
# Save task progress so a later handshake can recommend resuming it
brief = client.checkpoint(
agent_id="my_agent",
task="Research publication history",
recent_messages=["Still comparing two source timelines."],
checkpoint={
"currentStep": "Review affiliation conflict",
"nextStep": "Write corrected fact",
"openRisks": ["Two sources disagree on start year"],
},
)
if brief.session_recovery and brief.session_recovery.available:
client.resume_session(
agent_id="my_agent",
session_id=brief.session_recovery.session_id
)
session = client.inspect_session("my_agent")
print(session.has_checkpoint)
sessions = client.list_sessions(operator_state="interrupted", sort="operator")
print([(item.agent_id, item.operator_state) for item in sessions])
# Query facts
result = client.query("researcher/jane_smith", "affiliation")
if result.found:
print(result.value)
Error Handling
from iranti import IrantiClient, IrantiAuthError, IrantiValidationError, IrantiError
try:
result = client.write(...)
except IrantiAuthError:
print("Invalid API key")
except IrantiValidationError as e:
print(f"Bad input: {e}")
except IrantiError as e:
print(f"API error: {e}")
Environment Variables
| Variable | Description |
|---|---|
IRANTI_URL |
API server URL (default: http://localhost:3001) |
IRANTI_API_KEY |
API token (keyId.secret) or legacy shared server key |
License
AGPL-3.0-or-later.
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
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 iranti-0.4.1.tar.gz.
File metadata
- Download URL: iranti-0.4.1.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
748b7ec1f08b30d1dcac5688b865c792513496dbb4899f9a2774354c1645a5ba
|
|
| MD5 |
fceb6d205dc1fad92de1660eee5d74f1
|
|
| BLAKE2b-256 |
97597d8c6ce8629704052e49ac6e7f0efe422be4e62a92a80daa76a7a4c3ee8c
|
Provenance
The following attestation bundles were made for iranti-0.4.1.tar.gz:
Publisher:
publish-packages.yml on nfemmanuel/iranti
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iranti-0.4.1.tar.gz -
Subject digest:
748b7ec1f08b30d1dcac5688b865c792513496dbb4899f9a2774354c1645a5ba - Sigstore transparency entry: 1311387795
- Sigstore integration time:
-
Permalink:
nfemmanuel/iranti@fb394a76eb0a193ae3d043e7045999aa77984e09 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/nfemmanuel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-packages.yml@fb394a76eb0a193ae3d043e7045999aa77984e09 -
Trigger Event:
release
-
Statement type:
File details
Details for the file iranti-0.4.1-py3-none-any.whl.
File metadata
- Download URL: iranti-0.4.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae01f3469dc6f9e974fae2aa702689bc40557f4eabbaead06122dde76296254d
|
|
| MD5 |
c681e406c34f828dad7fc596f0a7ddd1
|
|
| BLAKE2b-256 |
e005ee2407fe82f9db1e5af4570895a2c0f204029a11c32fdc1e0a4fd0fbb9ee
|
Provenance
The following attestation bundles were made for iranti-0.4.1-py3-none-any.whl:
Publisher:
publish-packages.yml on nfemmanuel/iranti
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iranti-0.4.1-py3-none-any.whl -
Subject digest:
ae01f3469dc6f9e974fae2aa702689bc40557f4eabbaead06122dde76296254d - Sigstore transparency entry: 1311387860
- Sigstore integration time:
-
Permalink:
nfemmanuel/iranti@fb394a76eb0a193ae3d043e7045999aa77984e09 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/nfemmanuel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-packages.yml@fb394a76eb0a193ae3d043e7045999aa77984e09 -
Trigger Event:
release
-
Statement type: