Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lexicor_client-0.1.0a1.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

lexicor_client-0.1.0a1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

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

Hashes for lexicor_client-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 4e0e1600b6dab5f019f9718b5549e1a15cc032b8f05ce8d7123358e9f6101844
MD5 08adcda0d430296140ae88efed4e3bd5
BLAKE2b-256 a7cd19e271dfa603a0b7c6237c19a1762dee3be1f2f2d922ee1299f70442146c

See more details on using hashes here.

Provenance

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

Publisher: sdk-python-release.yml on thebigduck/Lexicor

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

File details

Details for the file lexicor_client-0.1.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for lexicor_client-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 19b36b2bc44d541b124b89e2d6b9b8b5cfe53065987339faedac84c49f3f0e1c
MD5 bdffff8fd7d4b152490f54aec1f9bef5
BLAKE2b-256 4da930c849f353727dd67513e37907c9344c49a773cf8f74f8218cc148864a65

See more details on using hashes here.

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

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