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/worker/proxy 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.10.0.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.10.0-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lange_python-0.10.0.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.10.0.tar.gz
Algorithm Hash digest
SHA256 9684380ef15983d1bec39004d167d4b45d439f8e44c0ac72b607c41d31dc2a1a
MD5 57a6206bc6d1242e682a89241a23b464
BLAKE2b-256 97cf197a4ad61c9ac1063939636cf0819180f9a4263838e1726cbe3bb2a25e52

See more details on using hashes here.

Provenance

The following attestation bundles were made for lange_python-0.10.0.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.10.0-py3-none-any.whl.

File metadata

  • Download URL: lange_python-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 40.1 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.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54070404a54a3f7ec71302069e81b02dfecabc6a3b38377f7d257ab6bb70f186
MD5 bd20d9906adb056cd8ec9ad1fda56b18
BLAKE2b-256 b76585ba9aa5edf40f11b751312ee66432b8f815c938cc51f0508102a211a23a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lange_python-0.10.0-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

This release

0.10.0 This release

2 files

0.9.1

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