Skip to main content

lange-python

Python helpers for Lange services.

The package is organized into two public domains:

  • lange.mesh contains mesh workers and plugins; its wire models live in lange.mesh.contracts.
  • lange.ai contains AI inference plugins, models, and servers; its model configuration types live in lange.ai.contracts.

Mesh Relay Worker

MeshWorker connects a local HTTP service to the Lange mesh relay and forwards public relay requests to your local target.

pip install lange-python
import asyncio
import os
import time

from lange.mesh import MeshRelayPlugin, MeshWorker

relay = MeshWorker(
    project_id=os.environ["MESH_PROJECT_ID"],
    plugins=[MeshRelayPlugin("http://localhost:3000")],
)

relay.start()

try:
    while relay.remote_relay_address is None and relay.is_alive():
        time.sleep(0.25)
    print(relay.remote_relay_address)
finally:
    asyncio.run(relay.stop())

The worker connects to wss://mesh.lange-labs.com by default and receives a public relay address for the project, such as https://my-project.mesh.lange-labs.com/.

If a mesh deployment requires bearer authentication, pass the token as api_key. Keep API keys in the environment or a local secret store instead of hardcoding them in application code.

import os

from lange.mesh import MeshRelayPlugin, MeshWorker

relay = MeshWorker(
    project_id=os.environ["MESH_PROJECT_ID"],
    plugins=[MeshRelayPlugin("http://localhost:3000")],
    api_key=os.environ["LANGE_LABS_API_KEY"],
)

The relay exposes lifecycle state for integrations:

  • remote_relay_address: public REST relay address returned by the mesh service

Stop the worker from an async context:

await relay.stop()

AI Inference Plugins

Install the backend required by the host platform, then attach one plugin per model. Default ports are assigned from 8500 in plugin order and can be overridden explicitly.

pip install "lange-python[ai-mlx]"
from lange.ai import MeshAiPlugin
from lange.ai.contracts import AiModelConfig
from lange.mesh import MeshWorker

model = AiModelConfig(
    model_name="example/model",
    model_alias="example",
    model_type="LLM",
    registration=None,
)
worker = MeshWorker(
    project_id="00000000-0000-0000-0000-000000000001",
    plugins=[MeshAiPlugin(model)],
)

Download files

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

Source Distribution

lange_python-0.9.1.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

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

lange_python-0.9.1-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file lange_python-0.9.1.tar.gz.

File metadata

  • Download URL: lange_python-0.9.1.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lange_python-0.9.1.tar.gz
Algorithm Hash digest
SHA256 07ba9da16be250762257ca7f4953868e83e4ada0f0e8bdc301abddd878a79909
MD5 0de4d7427acfc3819c1879545adb5992
BLAKE2b-256 5de1a3e592b3fef0eaf4f0648129fcf66dd37ca958abef911974de6064865cde

See more details on using hashes here.

Provenance

The following attestation bundles were made for lange_python-0.9.1.tar.gz:

Publisher: publish.yml on langelabs/lange-python

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

File details

Details for the file lange_python-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: lange_python-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 40.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lange_python-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0c5839495cc5c3e8769e056c8363cf8e5287baf51addcfa41e37a18d3637ed7
MD5 cdab1a20f29dcd2c4a905fdadabb816b
BLAKE2b-256 d9a67ae28c41969095aea6334e40fdd7b9ceff5bd9a2dbff5c7a6ce2910c6af6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lange_python-0.9.1-py3-none-any.whl:

Publisher: publish.yml on langelabs/lange-python

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

Release history Release notifications | RSS feed

0.10.0

2 files

This release

0.9.1 This release

2 files

0.9.0

2 files

0.7.3

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.5.0

2 files

0.3.32

2 files

0.3.31

2 files

0.3.30

2 files

0.3.29

2 files

0.3.28

2 files

0.3.27

2 files

0.3.26

2 files

0.3.25

2 files

0.3.24

2 files

0.3.23

1 file

0.3.22

2 files

0.3.21

2 files

0.3.19

2 files

0.3.17

2 files

0.3.16

2 files

0.3.15

2 files

0.3.14

2 files

0.3.13

2 files

0.3.12

2 files

0.3.11

2 files

0.3.10

2 files

0.3.9

2 files

0.3.8

2 files

0.3.7

2 files

0.3.6

2 files

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page