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/5xxreuse a singleIdempotency-Key, so a retried turn is never double-metered. - Typed results —
result.reply,.soul_state,.trace,.action,.rate_limit(limit/remaining/reset),.request_id. - Clear errors —
AuthError(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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bbd5086bf52736ccc25d6e287a07796cc9f664ccafcfbe3ada665f583891a25
|
|
| MD5 |
2d94bdd8fc28bfb6a0ca2f733ab38b4f
|
|
| BLAKE2b-256 |
2ea1965b3e7798fa4508caf550e146a36d459233c0e974f86c23fb130bf40419
|
Provenance
The following attestation bundles were made for leo_soul_client-0.1.0.tar.gz:
Publisher:
publish-sdk.yml on Kadropic-Labs/Soul
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leo_soul_client-0.1.0.tar.gz -
Subject digest:
7bbd5086bf52736ccc25d6e287a07796cc9f664ccafcfbe3ada665f583891a25 - Sigstore transparency entry: 2229463127
- Sigstore integration time:
-
Permalink:
Kadropic-Labs/Soul@61fc7bf71754c3fc3f2c29c5a64d09e0653b8f3b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Kadropic-Labs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@61fc7bf71754c3fc3f2c29c5a64d09e0653b8f3b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file leo_soul_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: leo_soul_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd4b2a46f4d8c56fea71a692d716a668afa06de64a529d5fc5ff4f77cc53ed08
|
|
| MD5 |
e2d45d1efad6226c1727de14774c7b1e
|
|
| BLAKE2b-256 |
d4fbc5ea4d98909cfd43ffc7a7cc932dc8e1c8def89262c5d0318ffab40b04b3
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
leo_soul_client-0.1.0-py3-none-any.whl -
Subject digest:
fd4b2a46f4d8c56fea71a692d716a668afa06de64a529d5fc5ff4f77cc53ed08 - Sigstore transparency entry: 2229463654
- Sigstore integration time:
-
Permalink:
Kadropic-Labs/Soul@61fc7bf71754c3fc3f2c29c5a64d09e0653b8f3b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Kadropic-Labs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sdk.yml@61fc7bf71754c3fc3f2c29c5a64d09e0653b8f3b -
Trigger Event:
workflow_dispatch
-
Statement type: