Skip to main content

Official Python SDK for InfoLang semantic memory (il-runtime).

Project description

InfoLang Python SDK

Official Python client for InfoLang semantic memory. Wraps the il-runtime REST API (Forge-compatible) with one-line construction, typed errors, automatic retries, and ergonomic agent helpers.

Repository: __REPO__. Package: infolang (PyPI).

Install

While the package is private, install from the repo:

pip install "infolang @ git+ssh://git@github.com/InfoLang-Inc/__REPO__.git@v0.1.0"

Once published:

pip install infolang

Quickstart

from infolang import InfoLang

il = InfoLang.from_api_key("il_live_...")          # managed cloud
result = il.investigate("How does auth middleware work?")
for chunk in result.chunks:
    print(chunk.score, chunk.text)

Three ways to call, depending on your runtime:

# 1. One-shot
chunks = InfoLang.from_api_key("il_live_...").investigate("query").chunks

# 2. Durable client (connection pooling)
with InfoLang.from_session_file() as il:        # OAuth via ~/.config/infolang/session.json
    il.memorize("a fact worth keeping", source="docs/auth.md")

# 3. Async
import asyncio
from infolang import AsyncInfoLang

async def main():
    async with AsyncInfoLang.from_api_key("il_live_...") as il:
        result = await il.recall("auth middleware", top_k=5)
        print(len(result.chunks))

asyncio.run(main())

Authentication

Mode Constructor Target
Managed cloud (API key) InfoLang.from_api_key("il_live_...") api.infolang.ai
Managed cloud (OAuth) InfoLang.from_session_file() api.infolang.ai
Self-hosted dev InfoLang.from_dev_key("key:namespace") 127.0.0.1:8766
Enterprise mTLS InfoLang.from_mtls("client.pem", "client-key.pem") self-hosted origin

Credentials are also read from the environment: INFOLANG_API_KEY, INFOLANG_DEV_KEY, INFOLANG_BASE_URL, INFOLANG_NAMESPACE.

Core API

Method Purpose
recall(query, *, namespace, top_k, filters, verbose) Semantic recall
recall_hybrid(query, *, namespace, top_k, tag_filter, candidate_pool, use_hybrid) Recall over a candidate pool with tag-inclusion ordering
investigate(query, *, namespace_hint, top_k=5) Agent-style recall
remember(text, *, source, tags, namespace) Store a memory
remember_batch(items, *, namespace, source) Store many memories in one call
memorize(content, *, source, tags, namespace) Alias of remember
forget(memory_id, *, namespace) Delete a memory
reset_namespace(namespace) Bulk clear a namespace (list + forget)
list_banks() / list_recent(*, namespace, n) Introspection
context_pack(query, *, namespace, max_tokens, repo_root) One-shot context string
ingest_repo(namespace, *, repo_root, ref) Index a repository
execute(operations) Batch ops
health.check() Liveness/readiness

Bulk ingest + hybrid recall (benchmarks / evals)

il = InfoLang.from_dev_key("devsecret:default")   # self-hosted runtime

il.reset_namespace("eval_run")                      # clean slate
il.remember_batch(
    [
        {"text": "Alice: I moved to Berlin in March 2024.",
         "tags": ["alice", "march", "2024", "session_1"]},
        {"text": "Bob: My flight is on the 12th.",
         "tags": ["bob", "session_2"]},
    ],
    namespace="eval_run",
)

hits = il.recall_hybrid(
    "When did Alice move to Berlin?",
    namespace="eval_run",
    top_k=20,
    tag_filter=["march", "2024"],   # restrict to chunks carrying these tags
    candidate_pool=500,
)
for chunk in hits.chunks:
    print(chunk.score, chunk.tags, chunk.text)

recall_hybrid fetches up to candidate_pool IL-ranked candidates, then (when tag_filter is given) re-orders so chunks sharing a tag come first and truncates to top_k. This biases a wide recall sweep toward tagged evidence — handy for evals/benchmarks — without requiring any server-side hybrid op.

Errors

All failures raise a subclass of InfoLangError: AuthenticationError, RateLimitError (with retry_after), NotFoundError, ValidationError, ServerError, plus InfoLangConnectionError for transport failures. Every API error carries status, body, and request_id.

Resilience

recall/remember and friends retry 429 and 5xx with exponential backoff plus full jitter (configurable via max_retries), and honor Retry-After. Timeouts default to connect 5s / read 30s.

Development

pip install -e ".[dev]"
ruff check .
mypy
pytest

The REST contract is pinned in openapi/ (see openapi/IL_RUNTIME_VERSION). Regenerate the typed models with scripts/codegen.sh after bumping the pin.

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

infolang-0.2.0.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

infolang-0.2.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file infolang-0.2.0.tar.gz.

File metadata

  • Download URL: infolang-0.2.0.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for infolang-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8690a69cb1ae23c4a873f21ec1d0c29d009832e01fbf0c24af4f8e48c889e227
MD5 259dacb1a81b5fe9b7518a60435778f1
BLAKE2b-256 76ed434097f8aad797d147435fad58f8badf90ebbe5d8e4a79ec4d8f224283c2

See more details on using hashes here.

File details

Details for the file infolang-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: infolang-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for infolang-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97282789727fe780d7d6ca5bcb266a3b93fdc951e33e22df6723f5ad47cb63e4
MD5 a6895e3a22a450ca9d5cbbe183c4a5f0
BLAKE2b-256 c7d0936e0699d275da2ad76a37676b05b4fd47ba025e137ac142229139c2f413

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