Skip to main content

langchain-pandex

LangChain tools for Pandex: search and read official law and case law from 25 countries and the EU, in the official wording, as it stood on any date, with the decisions that cite it.

Tool Name the model sees What it does
PandexSearch pandex_search Find passages of legislation and court decisions: words, a question, or a citation such as "§ 823 BGB" or an ECLI
PandexDocument pandex_document Read a law, one article of it, or a decision; at reads the wording in force on a past day
PandexCitations pandex_citations What cites a law, an article or a decision, the leading ones first (or what it cites)

Each tool returns the answer as text written for a model to read, the same text the Pandex MCP server gives. They are built on the pandex client; sync and async both work.

Install

pip install langchain-pandex
export PANDEX_API_KEY=px_...   # free key: https://www.pandex.io/key

Without a key the tools still work, with 50 calls a day per address.

Use the tools directly

from langchain_pandex import PandexCitations, PandexDocument, PandexSearch

search = PandexSearch()   # or PandexSearch(api_key="px_...")
print(search.invoke({"query": "right to erasure personal data", "jurisdiction": "eu", "kind": "legislation", "limit": 3}))

document = PandexDocument()
print(document.invoke({"id": "Code civil", "element": "1382", "at": "2015-01-01"}))
Code civil
code · 1804-03-21 · in force 1804-03-21– · fr · cited by 219346
id fr.dila_legi:LEGITEXT000006070721 · legifrance=LEGITEXT000006070721
https://www.legifrance.gouv.fr/loda/id/LEGITEXT000006070721

Livre III : Des différentes manières dont on acquiert la propriété › Titre IV : Des engagements qui se forment sans convention › Chapitre II : Des délits et des quasi-délits.
[art_1382] article 1382 (wording in force 1804-03-21–2016-10-01)
Tout fait quelconque de l'homme, qui cause à autrui un dommage, oblige celui par la faute duquel il est arrivé à le réparer.

Cited by 28493 decisions; the ones they cite most:
...
citations = PandexCitations()
print(citations.invoke({"id": "32016R0679", "element": "art_17", "limit": 3}))
Regulation (EU) 2016/679 ... (General Data Protection Regulation) ... art_17 [eu.legislation:32016R0679] is cited by 73 documents:
- 2022-02-24 CJ: Judgment of the Court (Fifth Chamber) of 24 February 2022. SIA 'SS' v Valsts ieņēmumu dienests. ... [eu.caselaw:62020CJ0175] at p_51, p_61 · cited by 12 of them
  "However, Article 23 of Regulation 2016/679 authorises the European Union and Member States to adopt a ‘legislative measure’ ..."
...

Use them in an agent

from langchain.agents import create_agent
from langchain_pandex import PandexCitations, PandexDocument, PandexSearch

agent = create_agent(
    "anthropic:claude-opus-5-5",   # any chat model with tool calling
    tools=[PandexSearch(), PandexDocument(), PandexCitations()],
    system_prompt=(
        "You answer questions on the law with the Pandex tools. Quote the official wording, "
        "name each text by its id and article, and say when you could not find something."
    ),
)
result = agent.invoke({"messages": [{"role": "user", "content": "What did article 1382 of the French Code civil say in 2015, and which decisions cite it most?"}]})
print(result["messages"][-1].text)

Arguments

  • PandexSearch: query, and optionally jurisdiction ("eu", "de", "fr,be"...), kind (legislation, decision, treaty), court, date_from, date_to, at, limit.
  • PandexDocument: id (a result id, or a citation: "BGB", "art. 6:162 BW", an ECLI, a CELEX number), and optionally element, at, history, continue_from, max_tokens.
  • PandexCitations: id, and optionally element, direction (in, out), order (leading, newest), limit.

Coverage, per country and source: https://www.pandex.io/coverage. The full API: https://docs.pandex.io.

Tests

pip install -e . pytest pytest-asyncio langchain-tests
pytest tests/unit_tests
PANDEX_API_KEY=px_... pytest tests/integration_tests   # calls the live API

The tools pass LangChain's standard ToolsUnitTests and ToolsIntegrationTests.

Licence

MIT. Maintained by Pandex.

Metadata

Release files for langchain-pandex 0.1.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 langchain-pandex 0.1.0
File Size Uploaded Provenance Actions
langchain_pandex-0.1.0.tar.gz 7.0 kB Without provenance Details for langchain_pandex-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-pandex 0.1.0
File Interpreter ABI Platform Actions
langchain_pandex-0.1.0-py3-none-any.whl Python 3 none any Details for langchain_pandex-0.1.0-py3-none-any.whl

Total release size: 14.3 kB

Release files / langchain_pandex-0.1.0.tar.gz

Download URL langchain_pandex-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
62ed0640f6e9f02a4bbcb79e24fc8cef1a19ce0d324988b7e231b0258f3f2116
BLAKE2b-256 checksum
How to use checksums
8b23626b070bc6e339f66620d46fdef509bb4f935500ead22ecf548ab69505ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / langchain_pandex-0.1.0-py3-none-any.whl

Download URL langchain_pandex-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b1c13faab31b9eade5b84d1be534eef033e44e3bbcd185713189dbe22641892
BLAKE2b-256 checksum
How to use checksums
66210a9d15ffce06f5712834f3dd064cf80c418c8419777b139961cb8553b122
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for langchain-pandex 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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