Skip to main content

Official Python client for the LEO Soul hosted API (metacognitive layer for LLM agents).

Project description

LEO Soul — Python client

Official, zero-dependency Python client for the LEO Soul hosted API — the stateless metacognitive layer for LLM agents.

pip install leo-soul-client

Quickstart

from leo_soul_client import LeoSoul

soul = LeoSoul(api_key="sk_live_...")             # from your dashboard

result = soul.turn(
    messages=[{"role": "user", "content": "Delete all my production data now."}],
    backend="openai",
    backend_kwargs={"api_key": "sk-...", "model": "gpt-4o-mini"},  # your model + key
)

print(result.action)      # answer | asked | confirmed | held | refused | escalated
print(result.reply)       # the processed reply to send to your user
store(result.soul_state)  # persist this; pass it back next turn — that's the learning

The one rule: round-trip soul_state

state = None
for user_msg in conversation:
    result = soul.turn(messages=[*history, user_msg], soul_state=state, backend="openai",
                       backend_kwargs={"api_key": OPENAI_KEY, "model": "gpt-4o-mini"})
    state = result.soul_state   # store it (a few KB of JSON) and send it back next turn

We keep none of it — soul_state is your agent's memory and it lives on your side.

Features

  • Zero dependencies — pure standard library. No native build, installs anywhere.
  • Exactly-once retries — automatic retries on 429/5xx reuse a single Idempotency-Key, so a retried turn is never double-metered.
  • Typed resultsresult.reply, .soul_state, .trace, .action, .rate_limit (limit/remaining/reset), .request_id.
  • Clear errorsAuthError (401/403), QuotaExceeded (402), RateLimitError (429, with .retry_after), LeoSoulError (everything else), each carrying .status, .type, and .request_id.

Self-hosted / on-prem

Point the client at your own deployment:

soul = LeoSoul(api_key="sk_live_...", base_url="https://soul.your-company.internal")

Personas

result = soul.turn(
    messages=msgs,
    persona={
        "identity": "a careful financial-support assistant",
        "values": ["truthfulness over agreeableness"],
        "red_lines": ["never give individualized investment advice"],
    },
    backend="openai",
    backend_kwargs={"api_key": OPENAI_KEY, "model": "gpt-4o-mini"},
)

Or reference a saved persona from your dashboard with persona_id=....

Error handling

from leo_soul_client import RateLimitError, QuotaExceeded, AuthError, LeoSoulError

try:
    result = soul.turn(messages=msgs, backend="mock")
except QuotaExceeded as e:
    ...  # upgrade the plan; e.request_id for support
except RateLimitError as e:
    time.sleep(e.retry_after)
except AuthError:
    ...  # bad key / IP not allowlisted

© Kadropic Labs. Part of Project LEO.

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

leo_soul_client-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

leo_soul_client-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file leo_soul_client-0.1.0.tar.gz.

File metadata

  • Download URL: leo_soul_client-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for leo_soul_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7bbd5086bf52736ccc25d6e287a07796cc9f664ccafcfbe3ada665f583891a25
MD5 2d94bdd8fc28bfb6a0ca2f733ab38b4f
BLAKE2b-256 2ea1965b3e7798fa4508caf550e146a36d459233c0e974f86c23fb130bf40419

See more details on using hashes here.

Provenance

The following attestation bundles were made for leo_soul_client-0.1.0.tar.gz:

Publisher: publish-sdk.yml on Kadropic-Labs/Soul

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file leo_soul_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for leo_soul_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd4b2a46f4d8c56fea71a692d716a668afa06de64a529d5fc5ff4f77cc53ed08
MD5 e2d45d1efad6226c1727de14774c7b1e
BLAKE2b-256 d4fbc5ea4d98909cfd43ffc7a7cc932dc8e1c8def89262c5d0318ffab40b04b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for leo_soul_client-0.1.0-py3-none-any.whl:

Publisher: publish-sdk.yml on Kadropic-Labs/Soul

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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