Metadata-Version: 2.4
Name: langchain-clearsigned
Version: 0.1.0
Summary: LangChain tool for Clearsigned: calibrated claim verification for AI agents, paid per call over x402, receipts verified offline.
License: MIT
Project-URL: Homepage, https://clearsigned.com
Project-URL: Documentation, https://clearsigned.com/integrations#langchain
Project-URL: Repository, https://github.com/diawest82/langchain-clearsigned
Project-URL: Live quality, https://clearsigned.com/quality
Keywords: langchain,tool,verification,fact-checking,x402,calibration,agents
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-core>=0.3
Requires-Dist: x402[evm]>=2.19
Requires-Dist: httpx>=0.27
Requires-Dist: eth-account>=0.13
Requires-Dist: cryptography>=42
Dynamic: license-file

# langchain-clearsigned

A LangChain tool that gives any agent an adversarial verify step: Clearsigned checks one factual
claim against live web evidence and returns `SUPPORTED`, `REFUTED` or `UNVERIFIABLE` with a
confidence that is a measured realized rate from a published calibration curve, every source
with its stance, and an Ed25519-signed receipt this tool verifies offline against Clearsigned's
pinned published key before any of it reaches the agent.

Each call pays $0.05 USDC over x402 (Base mainnet) from a key you hold. The price never depends
on the verdict; refunds exist only for failure to deliver. `UNVERIFIABLE` is a real answer: the
engine abstains rather than guesses.

## Install

```bash
pip install langchain-clearsigned
export CLEARSIGNED_BUYER_KEY=0x…   # an EVM key holding a little USDC on Base mainnet
```

## Use

```python
from langchain_clearsigned import ClearsignedVerifyTool
from langgraph.prebuilt import create_react_agent

agent = create_react_agent(model, [ClearsignedVerifyTool()])
agent.invoke({"messages": [("user", "Is it true that the Eiffel Tower is in Paris? Verify first.")]})
```

The tool returns a JSON string:

```json
{"verdict": "SUPPORTED", "confidence": 0.914,
 "confidence_meaning": "measured realized rate under engine-pkg-groq-20260925-n204",
 "evidence": [{"source": "https://en.wikipedia.org/wiki/Eiffel_Tower", "stance": "supports"}],
 "receipt_id": "…", "signature_verified_offline": true}
```

A receipt whose signature does not verify comes back as `RECEIPT_SIGNATURE_INVALID` and nothing
from it is passed on. Verdicts take about 5 to 15 seconds.

## Without a wallet

`buy_verdict(claim, exchange=..., pinned=...)` accepts an injected exchange function and pinned
key, which is how the package's own tests run: no network, no wallet, receipts signed with a
throwaway key through the production recipe.

## How to check Clearsigned

- Pin the key at https://verify.clearsigned.com/pubkey (this tool does).
- Walk the public hash-chained receipt ledger at https://verify.clearsigned.com/ledger/verify.
- Live quality figures: https://clearsigned.com/quality · serving curve: https://clearsigned.com/stats.json.

## Source of truth

Developed in the Clearsigned monorepo (`products/langchain-clearsigned/`) and mirrored to
https://github.com/diawest82/langchain-clearsigned. Changes land in the monorepo first.
