langchain-lexmex
Tool de LangChain para consultar LEX-MEX — asesor jurídico con IA sobre las 316 leyes federales mexicanas vigentes, sincronizadas con diputados.gob.mx. Respuestas citadas con ley y artículo exacto, sin alucinaciones.
Instalación
pip install langchain-lexmex
Credenciales
Necesitas una API key de LEX-MEX. Se obtiene registrándote como
humano en lex-mex.xyz (Google OAuth) y
generándola en POST /api/v1/keys — hay plan VIP (ilimitado) y
pay-as-you-go por créditos.
import os
os.environ["LEXMEX_API_KEY"] = "lmx_live_..."
Uso
from langchain_lexmex import LexMexTool
tool = LexMexTool() # toma LEXMEX_API_KEY del entorno
resultado = tool.invoke(
"¿Cuáles son las causales de despido justificado según la LFT?"
)
print(resultado)
Dentro de un agente
from langchain.agents import create_agent
from langchain_lexmex import LexMexTool
agent = create_agent(
model="claude-sonnet-4-6",
tools=[LexMexTool()],
)
agent.invoke({
"messages": [{"role": "user", "content": "¿Qué dice el artículo 47 de la LFT?"}]
})
Async
Instala el extra async (pip install langchain-lexmex[async]) y
usa await tool.ainvoke(...).
Seguridad
- La API key nunca se incluye en la serialización de la tool
(
model_dump()/repr()), para evitar que quede persistida en logs, tracing de LangSmith o checkpoints de LangGraph. - El endpoint de LEX-MEX es fijo (
https://lex-mex.xyz) y no es configurable desde fuera, para evitar que la key termine enviándose a un host arbitrario.
Changelog
- 0.2.0 — Fixes de seguridad:
api_keyexcluida de la serialización; se removió el parámetro configurableapi_base(ahora fijo). Se agregó headerX-LexMex-Clientpara analítica de uso por integración. - 0.1.0 — Versión inicial.
Licencia
MIT
Release files for langchain-lexmex 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_lexmex-0.2.0.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_lexmex-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / langchain_lexmex-0.2.0.tar.gz
| Download URL | langchain_lexmex-0.2.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b92aa6c60bc8437996bafc3aa4c98c8277b77b0ccc292e96a537e34cdbaf13ad
|
|
BLAKE2b-256 checksum How to use checksums |
89f4d95c318bf1a8e79d30d3a49387c751fd44d739035b0608445cfcb3cd7388
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / langchain_lexmex-0.2.0-py3-none-any.whl
| Download URL | langchain_lexmex-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16d14d2e1c0c970f452491c5da6bd2f739f55f9da64a2569da0a32b83cdb2ccb
|
|
BLAKE2b-256 checksum How to use checksums |
a46370095ddd5f87715dbe2e6cba94f9940784ca4ef84df508099aaf8df4872e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|