Skip to main content

  Loko - Extensions


Loko Extensions helps in writing LoKo's custom components.

Docs | Tutorial | LoKo AI

Installation

   (.venv) $ pip install loko-extensions

Example

To create new components you have to define its inputs, outputs and arguments:

from loko_extensions.model.components import Arg, Input, Output, Component, save_extensions

n = Arg(name="n", type="number", label="n", helper='Number of # in the output', value=1)
input = Input(id='input', label='Input', service='myfirstservice', to='output')
input_f = Input(id='file', label='File', service='upload_file', to='output')
output = Output(id='output', label='Output')
comp1 = Component(name="My First Component", args=[n], inputs=[input, input_f], outputs=[output], group="Custom")
save_extensions([comp1])

And create your services:

import sanic
from loko_extensions.business.decorators import extract_value_args

app = sanic.Sanic('first_project')

@app.post('/myfirstservice')
@extract_value_args()
async def f(value, args):
    n = int(args.get('n'))
    return sanic.json(dict(msg=f"{'#'*n} {value} {'#'*n}"))

@app.post('/upload_file')
@extract_value_args(file=True)
async def f2(file, args):
    n = int(args.get('n'))
    return sanic.json(dict(msg=f"{'#'*n} File name: {file[0].name} {'#'*n}"))

app.run("0.0.0.0", port=8080)

Here is your new component in LoKo:

Metadata

Release files for loko-extensions 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for loko-extensions 0.0.3
File Size Uploaded Provenance Actions
loko-extensions-0.0.3.tar.gz 8.5 kB Without provenance Details for loko-extensions-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for loko-extensions 0.0.3
File Interpreter ABI Platform Actions
loko_extensions-0.0.3-py3-none-any.whl Python 3 none any Details for loko_extensions-0.0.3-py3-none-any.whl

Total release size: 17.9 kB

Release files / loko-extensions-0.0.3.tar.gz

Download URL loko-extensions-0.0.3.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bc018126103882e16d9721d4a34e706b32e248cc61dcf0d7f607cda8ec2288cb
BLAKE2b-256 checksum
How to use checksums
b79b59c1c1041f1f888700b94052cdd5f7fb4e5d691fbd89ede1eb5a9617f4e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / loko_extensions-0.0.3-py3-none-any.whl

Download URL loko_extensions-0.0.3-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f15e74c4d839fc6b082fc635c180945df46b9f6aecc0a3ce023ca74edc10eb6
BLAKE2b-256 checksum
How to use checksums
797d97c19fe6a71ff0b303e813f3bed637824845b7d632619c98664e768e551f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Security for loko-extensions 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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