For the complete documentation index, see llms.txt. This page is also available as Markdown.

LangExtract

Set up LangExtract with Ollama and expose it as a local API for PDI.

These commands assume macOS or Linux.

Use equivalent paths and activation commands on Windows.

Architecture

PDI → HTTP Client → LangExtract API → Ollama model → JSON response

Prerequisites

Component
Version
Notes

Pentaho Data Integration

9.x

Community or EE. Spoon and Pan available.

Python

3.10+

Requires pip and venv.

LangExtract

Current GitHub source

Installed from google/langextract.

FastAPI

Current

REST wrapper for LangExtract.

Uvicorn

Current

ASGI server for the API.

Ollama

0.3+

Local LLM runtime.

Ollama Python package

Current

Required by the sample service code.

Model

llama3.1:8b

Pulled locally with Ollama.

PostgreSQL

Optional

Use only if you plan to persist extracted records.

1

Create project directory

Windows (PowerShell)

Unix

2

Create and activate virtual environment

Windows

Unix

3

Install dependencies

Identical on both platforms:

4

Save the script

Save server.py into the project directory:

  • Windows: C:\langextract_api\server.py

  • Unix: /opt/langextract_api/server.py

Save this file as server.py:

3KB
Open
5

Pull the Ollama model

Identical on both platforms:

6

Start Ollama

Identical on both platforms:

Leave this running in a separate terminal, or configure it as a service (see step 8).

7

Start the LangExtract service

Windows

Unix

Run as a background service

Windows - NSSM

Unix - systemd

Create /etc/systemd/system/langextract.service:

Then enable and start:

bash

8

Open firewall

Windows

Unix (ufw)

Unix (firewalld / RHEL)

9

Verify

Identical on both platforms:

Response:

Swagger UI (browser): http://localhost:8765/docs


Verify with a test request

Windows

Run a test extraction:

Response:

Unix

Run a test extraction:

Response:

Success means the API returns an extractions array with extracted values and character offsets.

Call the API from PDI

Use the HTTP Client step:

  • URL: http://localhost:8765/extract

  • Method: POST

  • Content-Type: application/json

  • Request body field: your JSON payload

  • Response field: response_json

Then parse the response with JSON Input:

  • Source is from a field: response_json

  • Path: $.extractions[*]

  • Fields: class, text, start, end


PostgreSQL


Troubleshooting

Last updated

Was this helpful?