Laya package – overview and setup
The Aeovi.Laya package brings fast, local AI decisions into your Robomotion flows. It talks to Laya, a small AI model that is built for deciding, not for writing. Laya never invents text. It only spreads probabilities over the answers you give it. That makes it predictable, cheap and very fast: a request with several decisions usually takes 20–40 ms on a graphics card.
Typical uses
- Routing e-mails and tickets to the right team
- Spotting refund or cancellation requests
- Detecting phishing
- Rating urgency or sentiment
- Pre-sorting documents before a human looks at them
The four nodes at a glance
| Node | Question type | Answer from Laya | Use it when … |
|---|---|---|---|
| Noul | Yes or no | noul: probability of “yes” from 0 to 1, plus route = yes no unsure | you need a yes/no answer and want to branch on it. Example: “Does the customer ask for a refund?” |
| Choice | Pick exactly one of several choices | choice: the picked choice, plus the probability of every choice | the answers are different things without an order. Example: which department, which topic, which product. |
| Score | Rate on an ordered scale | score: a number between the first and the last level, plus the probability of every level | the answers go from “little” to “a lot”. Example: urgency, anger, satisfaction, risk. |
| Advanced | Many questions of all three types at once | Laya’s full answer with one entry per question | you ask several things about the same text. Five questions cost hardly more time than one. |
All four nodes also work in batch mode: you pass many records (for example 1,000 e-mails) and every record gets the same question(s). See Batch mode.
Setup
What you need
- A running Laya server. Laya runs on your own machine or server. Nothing is sent to a cloud service.
- The Aeovi.Laya package in your Robomotion workspace.
- A robot that can reach the Laya server over the network (by default on the same machine).
Step 1 – Install and start the Laya server
Install Laya as described in the Laya repository. Then start the HTTP server. To understand German and other languages as well as English, load both models.
Windows (PowerShell)
$env:LAYA_MODELS = "english,multilingual"laya-serve
Linux / macOS
LAYA_MODELS=english,multilingual laya-serve
By default the server listens on port 8000. Check that it runs by opening this address in a browser:
http://127.0.0.1:8000/health
You should see "status":"ok" and the loaded models.
- Graphics card: with a CUDA graphics card a decision takes a few milliseconds. On a CPU Laya still works but needs roughly 0.2–0.5 s per request.
- First request: the very first request after starting the server takes about half a second longer while the model warms up.
Optional API key: if you start the server with the environment variable LAYA_API_KEY, every request must send this key. Store it in a Robomotion vault and select it in the node option API Key (optional).
Step 2 – Add the package to your flow
Open your flow in the Designer, search for Laya in the package panel and drag one of the nodes onto the canvas. The package is added to the flow’s dependencies automatically.
Step 3 – Your first decision
- Add an Inject node and a Function node with this code:
msg.text = "You charged my invoice twice, I want my money back!";return msg;
- Connect a Noul node. Keep the default question “Does the customer ask for a refund?”.
- Connect a Debug node and run the flow.
- In the debug output you see
msg.laya.noul(about 0.9) andmsg.laya.route= yes.
📷 Image placeholder: Screenshot of the canvas with Inject → Function → Noul → Debug, and the debug panel showing msg.laya with noul and route.
Settings that every node has
| Setting | Default | What it does |
|---|---|---|
| Text (input) | msg.text | What Laya looks at. A plain text or a whole object, for example an e-mail with subject and body. |
| Result (output) | msg.laya | Where the answer is written. Choose another name, for example msg.refund, when you use several Laya nodes in a row. |
| Batch | off | On: Text holds many records. See Batch mode. |
| Model | Auto | Auto lets Laya pick the model by the language of the text. Choose english or multilingual only if you know the language in advance. |
| Server URL | http://127.0.0.1:8000 | Address of the Laya server. Must start with http:// or https://. localhost is replaced by 127.0.0.1 automatically because that is a little faster on Windows. |
| API Key (optional) | empty | Only needed if the Laya server was started with LAYA_API_KEY. Select the vault item that holds the key. |
| Timeout (sec) | 30 | Maximum time the node waits for Laya. After that it fails with an error. |
Every input field can be filled from Custom (fixed value), Message (msg.…) or JS (a JavaScript expression), like in the standard Robomotion nodes.
- Do not force english for German texts. In our tests the answers became clearly wrong. Keep Auto if in doubt.
- Laya only reads text. Convert PDFs, Word files or scans to text first.
Reading the result
The nodes write Laya’s answer unchanged into Result. Field names are Laya’s own names. Only the Noul node adds one extra field, route, to make branching easy. Fields you will meet in every answer:
| Field | Meaning |
|---|---|
type | noul, choice or score |
answer_confidence | How sure Laya is about the answer it gives, from 0 to 1. This is the number to use for thresholds. |
confidence | A second, uncalibrated measure. Laya itself recommends not to use it for thresholds. |
action | Internal value of Laya’s decision model. Not needed in flows. |
model | Name of Laya’s engine, for example laya-rl-agent. |
routing.model | Which model answered: english or multilingual. routing.detection.language shows the detected language. |
usage.truncated | true if the text was too long and Laya cut off the end. Then the decision is based on the beginning of the text only. |
low_confidence | Only present when you set Min Confidence and the answer is below it. |
To branch, use a standard Switch node after the Laya node, for example:
msg.laya.route == "yes" // Noulmsg.laya.choice == "Billing" // Choice
Batch mode
Turn on Batch when you have many records and want to ask every record the same question(s). Instead of a loop that calls Laya once per record, the node sends up to 64 records per request. With 1,000 e-mails and 7 questions each, our demo flow went from 45 ms to 17 ms per e-mail.
In batch mode, Text must be one of these:
A list of records – the result is a list in the same order (msg.laya[0], msg.laya[1] …):
msg.text = ["first text", "second text"];
An object with IDs – the result has the same IDs (msg.laya.T1, msg.laya.T2 …). This is the easiest way to match answers back to your records:
msg.text = { "T1": { "subject": "…", "body": "…" }, "T2": { "subject": "…", "body": "…" }};
Every entry in Result looks exactly like the result without batch mode. More than 64 records are split into several requests automatically. Empty records are rejected with an error that names the record.
Limitation: Laya’s batch interface does not support min_confidence. If Min Confidence is filled in while Batch is on, the node stops with an error. Compare answer_confidence yourself instead.
Good questions, good results
- Ask one thing per question. “Does the customer ask for a refund?” works better than “Is the customer angry and wants a refund?”.
- Avoid negations. Ask “Does the customer want to cancel?” rather than “Does the customer not want to stay?”.
- Describe the choices. In Choice, a short description per choice (“invoices and payments”) improves accuracy noticeably.
- Only send what matters. Extra fields like IDs, headers or signatures distract Laya. In a test, a refund request dropped from 0.89 to 0.67 when the e-mail was wrapped in a large object with headers and CRM data.
- Test thresholds with your own data. Laya’s confidence values are optimistic out of the box. Run 50–100 real examples and look where wrong answers start.
- Keep the number of choices small. Above about 20 choices accuracy drops. Split into two steps (department first, then topic).
Limits
| What | Limit |
|---|---|
| Text length | About 1,000 tokens (1–2 pages) are read. Longer texts are cut and usage.truncated is true. |
| Input type | Text or JSON only. No images, no files. |
| Choices per Choice question | 2 to 100 (accuracy drops above about 20) |
| Levels per Score question | 2 to 32 |
| Questions per request (Advanced) | 64 |
| Records per batch request | 64 (the node splits larger batches) |
Errors that all nodes can report
| Message | Cause and fix |
|---|---|
Laya server at … is not reachable. Is laya-serve running? | The server is not started, runs on another port or a firewall blocks it. Open /health in a browser on the robot machine. |
Laya did not answer within … Increase Timeout or check the server | The server is overloaded or very slow (for example on CPU with long texts). Raise Timeout (sec) or check the server. |
Laya rejected the API key (401) | The server expects a key and none or a wrong one was sent. Check the vault item in API Key (optional). |
Laya is busy (503). Try again later | The server has too many requests at the same time. |
Laya reported error … | Laya rejected the request, for example because of too many choices. The message contains Laya’s reason. |
Server URL must start with http:// or https:// | Fix the Server URL option. |
Text is empty. Please pass a text or an object | The field selected in Text does not exist or is empty. Check the variable name, for example msg.text vs. msg.body. |
Batch: Text must be a list of records or an object with one record per ID | Batch is on but Text is a single text. Turn off Batch or pass a list/object. |
Min Confidence is not supported by Laya in batch mode | Clear Min Confidence or turn off Batch. |
A failing Laya node stops the flow like any other node. To continue anyway, add a Catch node or enable Continue On Error in the node’s common settings.