> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/devops/microservices/building-blocks/execution-handlers/ml-and-ai-handlers.md).

# ML & AI Handlers

ML & AI handlers add model inference, LLM orchestration, embeddings, and AI protocol support.

Use this page for handler-level details:

* Class names
* Handler parameters
* Runtime dependencies
* Built-in variants

Use [ML & AI Actions](/devops/api-event-and-process-flows/configuring-saga-steps/event-step/ml-and-ai-actions.md) for action-level saga step fields and parameters.

### Use ML Models

Classes:

* `com.rierino.handler.tensor.TensorScoreEventHandler`
* `com.rierino.handler.onnx.OnnxScoreEventHandler`
* `com.rierino.handler.pmml.PMMLScoreEventHandler`
* `com.rierino.handler.opennlp.OpenNLPScoreEventHandler`

Runs real-time inference using pre-trained ML models.

#### Handler parameters

| Parameter            | Definition                               | Example          | Default          |
| -------------------- | ---------------------------------------- | ---------------- | ---------------- |
| `model.state`        | State manager with model configurations  | `model`          | -                |
| `model.id`           | Model id to run on this handler instance | `recommendation` | -                |
| `model.store.system` | System used to store model assets        | `hdfs_default`   | -                |
| `model.local.dir`    | Local directory used for model assets    | `/tmp`           | `java.io.tmpdir` |

This handler supports caching.

#### Runtime dependencies

TensorFlow:

```gradle
implementation (group:'com.rierino.custom', name: 'tensor', version:"${rierinoVersion}")
```

ONNX:

```gradle
implementation (group:'com.rierino.custom', name: 'onnx', version:"${rierinoVersion}")
```

PMML:

```gradle
implementation (group:'com.rierino.custom', name: 'pmml', version:"${rierinoVersion}")
```

OpenNLP:

```gradle
implementation (group:'com.rierino.custom', name: 'opennlp', version:"${rierinoVersion}")
```

Action details: [Use ML Models](/devops/api-event-and-process-flows/configuring-saga-steps/event-step/ml-and-ai-actions/use-ml-models.md)

### Use GenAI Models

Class: `com.rierino.handler.rai.RAIModelEventHandler`&#x20;

Legacy: `com.rierino.handler.langchain4j.LangChainModelEventHandler`

Runs LLM chat and image generation flows through different LLM model providers.

{% hint style="info" %}
The legacy LangChain handler is replaced by RAI handler, which provides a more efficient implementation with more flexible runtime & chat model configurations.
{% endhint %}

#### Handler parameters

| Parameter        | Definition                                                       | Example       | Default  |
| ---------------- | ---------------------------------------------------------------- | ------------- | -------- |
| `model.state`    | State manager with model configurations                          | `genai_model` | -        |
| `model.domain`   | Model domain to include                                          | `chat`        | -        |
| `saga.handler`   | Saga handler used for tool sagas                                 | -             | `saga`   |
| `saga.state`     | State manager with saga definitions used as tools                | -             | `saga`   |
| `schema.state`   | State manager with schema definitions used for state tools       | -             | `schema` |
| `script.handler` | Event handler that is used for executing scripts generated by AI | -             | `script` |

Action details: [Use GenAI Models](/devops/api-event-and-process-flows/configuring-saga-steps/event-step/ml-and-ai-actions/use-genai-models.md)

### Perform Text Embedding

Class: `com.rierino.handler.rai.EmbeddingEventHandler`

Legacy: `com.rierino.handler.langchain4j.EmbeddingEventHandler`

Creates embeddings for search and retrieval use cases.4

{% hint style="info" %}
The legacy LangChain handler is replaced by RAI handler, which provides a more efficient implementation with more flexible configurations.
{% endhint %}

#### Handler parameters

For ONNX-based models:

| Parameter            | Definition                                 | Example           | Default                   |
| -------------------- | ------------------------------------------ | ----------------- | ------------------------- |
| `model.store.system` | System to fetch ONNX model files from      | `model_fs`        | default Hugging Face repo |
| `model.path`         | Model file path                            | `/model.onnx`     | default ONNX model        |
| `tokenizer.path`     | Tokenizer file path                        | `/tokenizer.json` | default tokenizer         |
| `model.local.dir`    | Local directory for downloaded model files | `/app/models`     | system temp dir           |

For custom embedding providers:

| Parameter          | Definition                                         | Example                                             | Default |
| ------------------ | -------------------------------------------------- | --------------------------------------------------- | ------- |
| `embedding.class`  | Java class implementing the embedding provider     | `dev.langchain4j.model.openai.OpenAiEmbeddingModel` | -       |
| `embeddingMethods` | Method configuration passed to the embedding class | `{"apiKey":"xxx"}`                                  | -       |

Action details: [Perform Text Embedding](/devops/api-event-and-process-flows/configuring-saga-steps/event-step/ml-and-ai-actions/perform-text-embedding.md)

### Service MCP Requests

Class: `com.rierino.handler.mcp.McpServerEventHandler`

Exposes existing microservice capabilities over MCP.

#### Handler parameters

| Parameter       | Definition                                        | Example       | Default       |
| --------------- | ------------------------------------------------- | ------------- | ------------- |
| `server.state`  | State manager with MCP server configurations      | `mcp_server`  | `genai_model` |
| `server.domain` | Server domain to include                          | `procurement` | -             |
| `saga.handler`  | Saga handler used for tool sagas                  | `ai_saga`     | `saga`        |
| `saga.state`    | State manager with saga definitions used as tools | `ai_saga`     | `saga`        |

Action details: [Service MCP Requests](/devops/api-event-and-process-flows/configuring-saga-steps/event-step/ml-and-ai-actions/service-mcp-requests.md)

### Service A2A Requests

Class: `com.rierino.handler.a2a.A2AServerEventHandler`

Exposes existing microservice capabilities over A2A.

#### Handler parameters

| Parameter       | Definition                                   | Example       | Default       |
| --------------- | -------------------------------------------- | ------------- | ------------- |
| `server.state`  | State manager with A2A server configurations | `mcp_server`  | `genai_model` |
| `server.domain` | Server domain to include                     | `procurement` | -             |
| `saga.handler`  | Saga handler used for tool sagas             | `ai_saga`     | `saga`        |

Action details: [Service A2A Requests](/devops/api-event-and-process-flows/configuring-saga-steps/event-step/ml-and-ai-actions/service-a2a-requests.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rierino.com/devops/microservices/building-blocks/execution-handlers/ml-and-ai-handlers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
