smart_ide/docs/features/langextract-api.md
Nicolas Cantu 088eab84b7 Platform docs, services, ia_dev submodule, smart_ide project config
- Add ia_dev submodule (projects/smart_ide on forge 4nk)
- Document APIs, orchestrator, gateway, local-office, rollout
- Add systemd/scripts layout; relocate setup scripts
- Remove obsolete nginx/enso-only docs from this repo scope
2026-04-03 16:07:58 +02:00

36 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# LangExtract — API locale (`services/langextract-api`)
## Objectif
Exposer [LangExtract](https://github.com/google/langextract) (Google, Apache-2.0) comme **service HTTP local** : à partir dun texte, dune consigne et dexemples few-shot, produire des **extractions structurées** (classes, attributs, texte extrait) avec **ancrage** dans le texte lorsque le modèle et la librairie le fournissent (`char_interval`).
## Périmètre
- Pas de logique métier supplémentaire : lAPI se limite à valider le JSON, appeler `langextract.extract`, sérialiser le résultat.
- Les modèles **cloud** (Gemini, etc.) suivent la configuration amont (clés API, quotas).
- Les modèles **locaux** passent typiquement par **Ollama** (`model_url`, options `fence_output` / `use_schema_constraints` selon la doc amont).
## Exploitation
| Élément | Détail |
|--------|--------|
| Code | [services/langextract-api/README.md](../../services/langextract-api/README.md) |
| Hôte / port | `127.0.0.1` et port par défaut `37141` (voir README) |
| Auth | Si `LANGEXTRACT_SERVICE_TOKEN` est défini : en-tête `Authorization: Bearer …` obligatoire sur `POST /extract` |
| Santé | `GET /health` |
## Schéma de requête (`POST /extract`)
Champs principaux : `text`, `prompt_description`, `examples[]` (`text`, `extractions[]` avec `extraction_class`, `extraction_text`, `attributes`), `model_id`, et options optionnelles alignées sur lAPI Python (`model_url`, `extraction_passes`, `max_workers`, `max_char_buffer`, `api_key`, `fence_output`, `use_schema_constraints`).
Réponse : `{ "documents": [ { "extractions": [ … ] } ] }` avec, par extraction, `extraction_class`, `extraction_text`, `attributes`, et `char_interval` `{ "start", "end" }` si présent.
## Intégration architecture
Ce service complète le socle décrit dans [system-architecture.md](../system-architecture.md) : un client (éditeur type Lapce, gateway, script) peut appeler lextraction structurée **sans** embarquer Python dans lUI, tant que le réseau local et le token le permettent.
## Références
- Dépôt amont : [https://github.com/google/langextract](https://github.com/google/langextract)
- PyPI : [https://pypi.org/project/langextract/](https://pypi.org/project/langextract/)