Skip to main content

sdeul

Structural Data Extractor using LLMs

CI/CD

Installation

$ pip install -U sdeul

Usage

Command Line Interface

  1. Create a JSON Schema file for the output

  2. Prepare a local model GGUF file or model API key.

  3. Extract structural data from given text using sdeul extract.

    Example:

    # Use OpenAI API
    $ sdeul extract --openai-model='gpt-4.1' \
        test/data/medication_history.schema.json \
        test/data/patient_medication_record.txt
    
    # Use Amazon Bedrock API
    $ sdeul extract --bedrock-model='us.anthropic.claude-sonnet-4-20250514-v1:0' \
        test/data/medication_history.schema.json \
        test/data/patient_medication_record.txt
    
    # Use Ollama API
    $ sdeul extract --ollama-model='gemma3:27b' \
        test/data/medication_history.schema.json \
        test/data/patient_medication_record.txt
    
    # Use a Llama.cpp GGUF model file
    $ sdeul extract --llamacpp-model-file='local_llm.gguf' \
        test/data/medication_history.schema.json \
        test/data/patient_medication_record.txt
    

    Expected output:

    {
      "MedicationHistory": [
        {
          "MedicationName": "Lisinopril",
          "Dosage": "10mg daily",
          "Frequency": "daily",
          "Purpose": "hypertension"
        },
        {
          "MedicationName": "Metformin",
          "Dosage": "500mg twice daily",
          "Frequency": "twice daily",
          "Purpose": "type 2 diabetes"
        },
        {
          "MedicationName": "Atorvastatin",
          "Dosage": "20mg at bedtime",
          "Frequency": "at bedtime",
          "Purpose": "high cholesterol"
        }
      ]
    }
    

REST API

SDEUL also provides a REST API for extracting structured data and validating JSON.

  1. Start the API server:

    $ sdeul serve
    
  2. The API will be available at http://localhost:8000 with the following endpoints:

    • POST /extract - Extract structured data from text
    • POST /validate - Validate JSON data against a schema
    • GET /health - Health check endpoint
    • GET /docs - Interactive API documentation
  3. Example API usage:

    # Extract data using OpenAI
    $ curl -X POST "http://localhost:8000/extract" \
      -H "Content-Type: application/json" \
      -d '{
        "text": "Patient is taking Lisinopril 10mg daily for hypertension.",
        "json_schema": {
          "type": "object",
          "properties": {
            "medications": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {"type": "string"},
                  "dosage": {"type": "string"},
                  "condition": {"type": "string"}
                }
              }
            }
          }
        },
        "openai_model": "gpt-4o-mini",
        "openai_api_key": "your-api-key"
      }'
    
    # Validate JSON data
    $ curl -X POST "http://localhost:8000/validate" \
      -H "Content-Type: application/json" \
      -d '{
        "data": {"medications": [{"name": "Lisinopril", "dosage": "10mg", "condition": "hypertension"}]},
        "json_schema": {
          "type": "object",
          "properties": {
            "medications": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {"type": "string"},
                  "dosage": {"type": "string"},
                  "condition": {"type": "string"}
                }
              }
            }
          }
        }
      }'
    

Release files for sdeul 0.2.0

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

Source distribution (sdist)

Source distribution for sdeul 0.2.0
File Size Uploaded
sdeul-0.2.0.tar.gz 208.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sdeul 0.2.0
File Interpreter ABI Platform
sdeul-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 245.1 kB

Release files / sdeul-0.2.0.tar.gz

Download URL sdeul-0.2.0.tar.gz
Size 208.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6918e0a6fcb90f2380a5d8fdca070497b4e058be94871db03813240b1ffd5aba
BLAKE2b-256 checksum
How to use checksums
c1d890ce11bd4c732a4efc6d68b7afa250525f476176497043e7170881af77ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / sdeul-0.2.0-py3-none-any.whl

Download URL sdeul-0.2.0-py3-none-any.whl
Size 36.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d5d240809f77bfc831b6932fd9b5d0004d24559699e7fd308537440b89bdaeb
BLAKE2b-256 checksum
How to use checksums
05235fcd6ac7f8bf6274e4d2222f8ef9c7abdd257d1be4cdf1e71de2137bfa11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

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