Skip to main content

Python bindings for Lyric: A Rust-powered secure sandbox for multi-language code execution, leveraging WebAssembly to provide high-performance runtime isolation for AI applications

Project description

Lyric

A Rust-powered secure sandbox for multi-language code execution, leveraging WebAssembly to provide high-performance runtime isolation for AI applications.

✨ Features

  • 🛡️ Secure Isolation: Sandboxed environment based on WebAssembly for reliable runtime isolation
  • 🚀 High Performance: Built with Rust to ensure optimal execution performance
  • 🌐 Multi-language Support: Run Python, JavaScript, and more in a unified environment
  • 🔌 Easy Integration: Clean Python bindings for seamless integration with existing projects
  • 🎯 AI-Optimized: Runtime environment specifically optimized for AI applications

🚀 Quick Start

Installation

Install Lyric via pip:

pip install lyric-py

Install default Python webassembly worker:

pip install lyric-py-worker

Install default JavaScript webassembly worker:

pip install lyric-js-worker

Basic Usage

import asyncio
from lyric import DefaultLyricDriver

async def main():
    lcd = DefaultLyricDriver(host="localhost", log_level="ERROR")
    lcd.start()

    # Load workers(default: Python, JavaScript)
    await lcd.lyric.load_default_workers()

    # Execute Python code
    python_code = """
    def add(a, b):
        return a + b
    result = add(1, 2)
    print(result)
    """

    py_res = await lcd.exec(python_code, "python")
    print(py_res)

    # Execute JavaScript code
    js_code = """
    console.log('Hello from JavaScript!');
    """

    js_res = await lcd.exec(js_code, "javascript")
    print(js_res)

    # Stop the driver
    lcd.stop()

asyncio.run(main())

Function Execution

import asyncio
import json
from lyric import DefaultLyricDriver

async def main():
    lcd = DefaultLyricDriver(host="localhost", log_level="ERROR")
    lcd.start()

    # Load workers(default: Python, JavaScript)
    await lcd.lyric.load_default_workers()
    py_func = """
def message_handler(message_dict):
    user_message = message_dict.get("user_message")
    ai_message = message_dict.get("ai_message")
    return {
        "user": user_message,
        "ai": ai_message,
        "all": [user_message, ai_message],
        "custom": "custom",
        "handler_language": "python",
    }
"""
    input_data = {
        "user_message": "Hello from user",
        "ai_message": "Hello from AI",
    }
    input_bytes = json.dumps(input_data).encode("utf-8")
    py_res = await lcd.exec1(py_func, input_bytes, "message_handler", lang="python")
    # Get the result of the function execution
    result_dict = py_res.output
    print("Python result:", result_dict)
    print(f"Full output: {py_res}")

    js_func = """
function message_handler(message_dict) {
    return {
        user: message_dict.user_message,
        ai: message_dict.ai_message,
        all: [message_dict.user_message, message_dict.ai_message],
        custom: "custom",
        handler_language: "javascript",
    };
}
"""
    js_res = await lcd.exec1(js_func, input_bytes, "message_handler", lang="javascript")
    # Get the result of the function execution
    result_dict = js_res.output
    print("JavaScript result:", result_dict)
    print(f"Full output: {js_res}")

    # Stop the driver
    lcd.stop()

asyncio.run(main())

🔧 Requirements

  • Python >= 3.8

🤝 Contributing

We welcome Issues and Pull Requests! Please check out our Contributing Guidelines for more information.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details

⭐️ Show Your Support

If you find Lyric helpful, please give us a star! It helps others discover this project.

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

lyric_py-0.1.1.tar.gz (102.0 kB view details)

Uploaded Source

Built Distributions

lyric_py-0.1.1-pp310-pypy310_pp73-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded PyPy musllinux: musl 1.2+ x86-64

lyric_py-0.1.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.7 MB view details)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

lyric_py-0.1.1-pp39-pypy39_pp73-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded PyPy musllinux: musl 1.2+ x86-64

lyric_py-0.1.1-pp38-pypy38_pp73-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded PyPy musllinux: musl 1.2+ x86-64

lyric_py-0.1.1-cp312-none-win_amd64.whl (11.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

lyric_py-0.1.1-cp312-cp312-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

lyric_py-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

lyric_py-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (10.7 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

lyric_py-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.12 macOS 10.12+ x86-64

lyric_py-0.1.1-cp311-none-win_amd64.whl (11.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

lyric_py-0.1.1-cp311-cp311-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

lyric_py-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

lyric_py-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (10.7 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

lyric_py-0.1.1-cp311-cp311-macosx_10_12_x86_64.whl (11.2 MB view details)

Uploaded CPython 3.11 macOS 10.12+ x86-64

lyric_py-0.1.1-cp310-none-win_amd64.whl (11.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

lyric_py-0.1.1-cp310-cp310-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

lyric_py-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

lyric_py-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (10.7 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

lyric_py-0.1.1-cp39-none-win_amd64.whl (11.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

lyric_py-0.1.1-cp39-cp39-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

lyric_py-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

lyric_py-0.1.1-cp39-cp39-macosx_11_0_arm64.whl (10.7 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

lyric_py-0.1.1-cp38-none-win_amd64.whl (11.9 kB view details)

Uploaded CPython 3.8 Windows x86-64

lyric_py-0.1.1-cp38-cp38-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

lyric_py-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

File details

Details for the file lyric_py-0.1.1.tar.gz.

File metadata

  • Download URL: lyric_py-0.1.1.tar.gz
  • Upload date:
  • Size: 102.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.4

File hashes

Hashes for lyric_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 024236f92312df04774074eebba5f7aad9f17f4501a937a6fdc5ed3b93adcadb
MD5 abbe06eb173744eacd1777efeba9915d
BLAKE2b-256 61fcdd6e05301698175484b42e60eb50b9e7eb2949b5c14decbae00b682731ea

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-pp310-pypy310_pp73-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-pp310-pypy310_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 dbe1b8debb97adde3b8cdcdf71a03b7689abd677b666b58a28c246ec2dc9189c
MD5 2dc70b082f7b7f1d672169e1051c3c89
BLAKE2b-256 f1b8e3e694f8aed345bdc9fb479e02a665d74e113716efddbd4abcde604600d4

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cce2d4ca0c9e4787154d85f9ac20db78a839092bd80da1c5e3cf23055b2c18d1
MD5 b3cb4e74c8e5f40a66e591fc0ad78d9a
BLAKE2b-256 bc70377f809de968e791db80ca9310169a82646a0fbf26a919b1be758b4799a3

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-pp39-pypy39_pp73-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-pp39-pypy39_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1a61413a47d3cd1ad00819c0c712a596fc51c39bffd8cb224bddd0de0ca8bf1b
MD5 5cdd2f52ab7672ec2cd139fce5d250da
BLAKE2b-256 324f20ac5e7372dc4eae1e394d47f2e4c271cec39fd864e629296a2ac05b37ca

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-pp38-pypy38_pp73-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-pp38-pypy38_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 524157fe906e7d803cfa3cef8c525c2a10dc10bf760441022ab421a9d08e4365
MD5 3c70da99d12a5ea31a316a9f80e3c0fb
BLAKE2b-256 fbf11ee02720b5421e2ddea5f422fcb0eb8aa5aa05464726c1e89ca597ae6dae

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 0249cd1b52fd75e31339a6922b303b49a9750ff7119e7f4b96cb69a17b81b736
MD5 f6a2352cef74d2305e90dbf40781b010
BLAKE2b-256 937660081f429b187386cf5f7765cc09b0c379773e059d07e694dea95f2f43aa

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 29a9e857b8fcf5a181d95b31fe78f925d739d1759dde40aad7abd1ee0aad2a26
MD5 18e01d47960ac1e000b473825bf3381d
BLAKE2b-256 bd87ac0a829258e96d8f203ace3699f1c1ca5b77ef8ffee0d72d22f06c184e33

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 555bd371e1c0928a3436af417caaed9693644bdc1bae0bb9d1a36eeb579c5f2f
MD5 c21b3f6a74f710596d25ac2b58024319
BLAKE2b-256 4934d1b204f4dc05802f152789212db7ddb157a6dab0839683c07af61dfe1db4

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b535815362d47e16675383259af04342a372a7cf47f572dc477c1209fc775d58
MD5 5cef5cf7ed0c544e55bf0df83e86df66
BLAKE2b-256 81f3f81e7e56f35a7752e83fdae1ab5b802c52343daa52871fe1b9d73474991a

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 68def475b7006f9330010809022dba3676662ceae3ca035b61af70efe521952d
MD5 965e648c9058a927dfe8f602f25dc09d
BLAKE2b-256 c46b9c1e18750e978b1c0e19c36693c1c24ae60d7011b78a98288cfb74dfee33

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 69a5a58838c587144deb8d351c78f55b31b4a6f1c092ffd809bd205e161e3a6c
MD5 5ca1a83ca93b980673537df146a0c536
BLAKE2b-256 f4949e20aa939d41437c09c0c08b050aaf5b3067916093fe2e0aab14417d828c

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7176a91768ac120dde41179ac13926290c87d9e76b7d78cffa8a3f369e7968c2
MD5 9269ee3b50df6fb99f96a505f124ca75
BLAKE2b-256 04544fce031e0e67dc4d20615bd8c970e912703a136aefeb2c33f4ca3e580b2f

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c5db421878a5c1f7903f6b15f84c32078858f2c4209ee7cc1932ddc6f7cabf32
MD5 84e844a7402671317d6672ea82ff7a8e
BLAKE2b-256 0f97b9e12ae2877ce6a966047c0caaf6402ed559be67acd09417f0032eaee76a

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a28826004b5be6308cc8335d081786acd15dccd8fb3411042e0266774a5f2a12
MD5 94003f7a88b5802d33ac4204af61a641
BLAKE2b-256 ed54ebaf3454c63a3d3fb6bfd408d4750bc3576c6d1b6b3fb2a92d02bb8f69de

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0c6f9032531461d1d4a50e350d72882f7e6da8d817ef3a4be890f9ee21ce6441
MD5 b4c00e034bca7d30d19ca0326e903a2c
BLAKE2b-256 9932f0f15aa3753af0c723d4d9fb66d5112ef404d6df3e2c916a170c7d727260

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 d22d59d283afe3004d4d374838df115058287c64abe4c89b181e050606f01aba
MD5 5a2c48d54d0bea3dd146f2efef68c3e7
BLAKE2b-256 7cd56dd5f4358c3ba0d75b3f55925166cfae8e014a1c1e12670502af6e003f7c

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fdf4b63ea096444d9db756ae64e2a97f0aaeb14eed999a642f91aa540a30f3e8
MD5 5529368aeb5172720f751e4d9b8259b2
BLAKE2b-256 fb850f28ed79364ea8572638bc39c0ce14b960afbc487f77245f7b79fe350106

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eafc54b8337b20b1c7e032f00a8b39a7de62cdcf7500a915692133f7e89c07c0
MD5 31fbadb57b913099a095cf38786ebc6a
BLAKE2b-256 b1357e33e201e0dd9215c414a40c3c296d7a79054c6336a6fd01e77633ce069a

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 973fc1b3526d4193a7e7fc17103ceaec2e727a74debf1306b87a75b14b9562ed
MD5 eb859053d7a2ae3c1b000c24e7850b4e
BLAKE2b-256 fb0cf3de8b0872a255240f0cb6ac215639cea2a3e6798fe461066445eb6f30da

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 1b3f8483b12e338dff5d97bf39e1fa66fdb57afebe403bcef90b6b7e2ac3c349
MD5 d00b5f67f9f4ef7253ed5044eb632816
BLAKE2b-256 50ea1998c955c97db94735926c0c73aba8a24893a5cc58e2dcf52b5666920682

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4f4c591803c44927a871527a2850e630deb84e9487fc2fb1e7b5e97982f91ecf
MD5 c65e151033835b771a3c29942433e909
BLAKE2b-256 81243822eb754d6182308f56aebd0570e717f154a01783432bca487e69440234

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd2bb5835d31e5e7b7f31de9332f39112b6899df1af44bea70632b4bfaba8d16
MD5 251c0f6e4631489911c98dbe6a6a8898
BLAKE2b-256 7db16de26f22289325949932630d975060f0da42106b8e56175a2c968e5316b1

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f519c3175962b6508a45143e97bf9dd202056a1473fa9d409dd7ab4a1f9271e
MD5 ae51520ce86aadd750606721be1b9f83
BLAKE2b-256 3c78f4b80cae0c8630e34fb8052c555bb6ba956f96552850dc9be64d7a59af49

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp38-none-win_amd64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 7c82505f486ff5d0f25e564f6973f9465206cc98faa6d0cb16ce18e19ffe8179
MD5 7cfdbe59b81936d15c7feaa5f36745dc
BLAKE2b-256 3fa587b5a7ed7082c82486f968197ca96d4cd4504f1f215590a7d9bb350846a3

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp38-cp38-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e6616345dfe0e9af2e63cd093509664681bc9142cb0d1abb9be2935316eaac9a
MD5 655ed6f717f5f8ee45648e7c635bcdaa
BLAKE2b-256 f46cfde99da9988790962ae0ddea3e2bc21fd68c96dc6914d911f04d190026ce

See more details on using hashes here.

File details

Details for the file lyric_py-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lyric_py-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d2211710144d1734610c38a68e54c315b0a83737078d595745f1440f1ae64074
MD5 020e1da952ccd3d85096e58caab2463e
BLAKE2b-256 d33fcfe66eea2e6c49706e5753d7c3ca5f9cfa051792401c165a45f1b496029c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page