Metadata-Version: 2.5
Name: langchain-machinelibrary
Version: 0.1.1
Summary: LangChain retriever and tools for Machine Library: citable search over papers, books, patents, standards and Wikipedia.
Project-URL: Homepage, https://machinelibrary.ai
Project-URL: Repository, https://github.com/SpaceFrontiers/machinelibrary-integrations
Project-URL: Documentation, https://machinelibrary.ai/docs/api
License-Expression: MIT
License-File: LICENSE
Keywords: citations,langchain,machine-library,retriever,scholarly-search,tool
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.10
Requires-Dist: langchain-core<2,>=0.3
Requires-Dist: machinelibrary<0.2,>=0.1.0
Description-Content-Type: text/markdown

# langchain-machinelibrary

[Machine Library](https://machinelibrary.ai) for LangChain: a retriever and agent
tools for citable search across scholarly papers, books, patents, standards and
Wikipedia (plus Reddit, Telegram and Discord). Results carry a canonical
`source_uri`, so answers can cite sources a reader can open and check.

## Install

```bash
pip install langchain-machinelibrary
export MACHINELIBRARY_API_KEY=ml_...   # https://machinelibrary.ai/keys
```

## Retriever (RAG)

```python
from langchain_machinelibrary import MachineLibraryRetriever

retriever = MachineLibraryRetriever(k=5)
for doc in retriever.invoke("perovskite solar cell stability under humidity"):
    print(doc.metadata["title"], doc.metadata["source"])
    print(doc.page_content)
```

## Agent tools

```python
from langchain.agents import create_agent
from langchain_machinelibrary import MachineLibraryToolkit

agent = create_agent(
    "anthropic:claude-sonnet-5-5",
    tools=MachineLibraryToolkit().get_tools(),
    system_prompt="Answer from Machine Library sources and cite each claim's source_uri.",
)
agent.invoke({"messages": [{"role": "user", "content": "What limits lithium-metal anodes?"}]})
```

| Tool | Use |
| --- | --- |
| `machinelibrary_search` | Find documents; returns passages and `source_uri` |
| `machinelibrary_search_in_document` | Find passages supporting a claim inside one document |
| `machinelibrary_fetch_document` | Read bounded full text when the body is needed |

## Billing and limits

Each search or read is charged to the key's account; see
[pricing](https://machinelibrary.ai/pricing). Retrieved text is evidence to
review, not proof that a generated answer is correct. Coverage is broad but not
exhaustive.
