Python client SDK for the Lexicor API
Project description
Lexicor Python Client
Python SDK for the Lexicor API.
Installation
Once published to PyPI:
pip install lexicor-client
From this repo (editable):
pip install -e sdks/python
From GitHub without a clone:
pip install "git+https://github.com/thebigduck/Lexicor.git#subdirectory=sdks/python"
Publishing / tag process: ../PUBLISH.md.
Quick start
from lexicor_client import LexicorClient
client = LexicorClient("https://api.lexicor.io", api_key="lx-your-key")
ing = client.ingest("Schedule a follow-up with the team next Tuesday.", build_packet=False)
assert ing["parsed"]
my_graph = ing["intent_graph"]
normalized = client.normalize(my_graph)
result = client.roundtrip(my_graph)
comparison = client.compare(my_graph, normalized)
Ingress and LM fallback
Template ingress is the default. Enable model-backed parsing when no template matches (server must have OPENAI_API_KEY):
client.ingest(
"Some unusual directive…",
lm_fallback=True,
build_packet=True,
render_strategy="ascii_compact",
)
Negotiation and full packets
Advertise capabilities, confirm the session, then build and decode transport packets (same flow as POST /v1/negotiate/* and /v1/packet/*):
agent_id = "my-remote-agent"
client.negotiate_advertise(
agent_id,
supported_codecs=["lexicor-line-v1"],
supported_symbol_tables=["core-sym-1"],
supported_fidelity_tiers=[0, 1, 2, 3],
)
offer = client.negotiate_offer("sess-001", agent_id)
if offer["type"] != "offer":
raise RuntimeError(offer.get("reason", "negotiation failed"))
contract = offer["contract"]
client.negotiate_confirm("sess-001")
contract["session_id"] = "sess-001"
built = client.packet_build(
my_graph,
session=contract,
render_strategy="ascii_compact",
payload_mode="semantic_transport",
)
packet = built["packet"]
decoded = client.packet_decode(packet)
graph = decoded["intent_graph"]
Optional transport= (advanced): pass an httpx.BaseTransport when constructing LexicorClient for custom HTTP behavior.
Features
- Automatic retry with exponential backoff
- Rate limit handling (429 with Retry-After)
- Context manager support
- Type hints throughout
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 lexicor_client-0.1.0a1.tar.gz.
File metadata
- Download URL: lexicor_client-0.1.0a1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e0e1600b6dab5f019f9718b5549e1a15cc032b8f05ce8d7123358e9f6101844
|
|
| MD5 |
08adcda0d430296140ae88efed4e3bd5
|
|
| BLAKE2b-256 |
a7cd19e271dfa603a0b7c6237c19a1762dee3be1f2f2d922ee1299f70442146c
|
Provenance
The following attestation bundles were made for lexicor_client-0.1.0a1.tar.gz:
Publisher:
sdk-python-release.yml on thebigduck/Lexicor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lexicor_client-0.1.0a1.tar.gz -
Subject digest:
4e0e1600b6dab5f019f9718b5549e1a15cc032b8f05ce8d7123358e9f6101844 - Sigstore transparency entry: 2191097475
- Sigstore integration time:
-
Permalink:
thebigduck/Lexicor@54b7c58edf558261aa3497605806134c1296a987 -
Branch / Tag:
refs/tags/sdk-py-v0.1.0a1 - Owner: https://github.com/thebigduck
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python-release.yml@54b7c58edf558261aa3497605806134c1296a987 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lexicor_client-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: lexicor_client-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 10.7 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 |
19b36b2bc44d541b124b89e2d6b9b8b5cfe53065987339faedac84c49f3f0e1c
|
|
| MD5 |
bdffff8fd7d4b152490f54aec1f9bef5
|
|
| BLAKE2b-256 |
4da930c849f353727dd67513e37907c9344c49a773cf8f74f8218cc148864a65
|
Provenance
The following attestation bundles were made for lexicor_client-0.1.0a1-py3-none-any.whl:
Publisher:
sdk-python-release.yml on thebigduck/Lexicor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lexicor_client-0.1.0a1-py3-none-any.whl -
Subject digest:
19b36b2bc44d541b124b89e2d6b9b8b5cfe53065987339faedac84c49f3f0e1c - Sigstore transparency entry: 2191098672
- Sigstore integration time:
-
Permalink:
thebigduck/Lexicor@54b7c58edf558261aa3497605806134c1296a987 -
Branch / Tag:
refs/tags/sdk-py-v0.1.0a1 - Owner: https://github.com/thebigduck
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python-release.yml@54b7c58edf558261aa3497605806134c1296a987 -
Trigger Event:
push
-
Statement type: