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.0.tar.gz (24.3 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.0-py3-none-any.whl (39.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lange_python-0.9.0.tar.gz
  • Upload date:
  • Size: 24.3 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.0.tar.gz
Algorithm Hash digest
SHA256 7c3e5afd436066a8e4e75c675438f7c2c13d93ab989e1ff660cbbc99c0fe6a5e
MD5 8765e9c9443d2db0e2288a967f6abef7
BLAKE2b-256 b6b161389fd399a21a2fca8557e475788bf34a820e93377e8562d9659ddff980

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lange_python-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 39.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c71a3b417ac85f9d13c84d34bf89785727711b1eec6de17420aa57d915e40aef
MD5 b5207c3fd4627586307047acaddbd9ad
BLAKE2b-256 fa459dcc3cf8939ad2ad8b5cbcda4b4d43a0b6766589d25caa02f0f3de5d5c96

See more details on using hashes here.

Provenance

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

0.10.0

2 files

0.9.1

2 files

This release

0.9.0 This release

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