Skip to main content

LangExtract Service (Python)

This document describes the FastAPI application serving as a microservice for semantic enrichment using Google's LangExtract library.

Overview

This FastAPI application provides an API to extract structured information from text using LangExtract. It's designed to be a flexible service that can be used by other services in the ChainAlign ecosystem to add a layer of semantic understanding to text.

Key Functionalities Exposed:

  • Receiving text content, a prompt description, and examples.
  • Using LangExtract to extract entities, attributes, and relationships from the text.
  • Returning the extractions as a list of dictionaries.

Technology Stack:

  • FastAPI: For creating the web server and API endpoints.
  • LangExtract: The core library for semantic extraction.

API Endpoints

POST /extract

Extracts structured information from text using LangExtract.

Request Body:

{
"text_content": "The text content to be processed.",
"prompt_description": "A description of the extraction task.",
"examples": []
}

Responses:

  • 200 OK: A JSON object with the extracted information.
  • 422 Unprocessable Entity: If the request body is invalid.
  • 500 Internal Server Error: If the LangExtract extraction fails.