Metadata-Version: 2.4
Name: ppx-langchain
Version: 0.1.0a1
Summary: LangChain integration for the Preference Profile Exchange (PPX).
Project-URL: Homepage, https://blazing-customs.github.io/ppx-spec/
Project-URL: Documentation, https://github.com/Blazing-Customs/ppx-sdks/tree/main/python/ppx-langchain#readme
Project-URL: Source, https://github.com/Blazing-Customs/ppx-sdks/tree/main/python/ppx-langchain
Project-URL: Repository, https://github.com/Blazing-Customs/ppx-sdks
Project-URL: Issues, https://github.com/Blazing-Customs/ppx-sdks/issues
Project-URL: Changelog, https://github.com/Blazing-Customs/ppx-sdks/blob/main/CHANGELOG.md
Author: Blazing Customs
License: Apache-2.0
License-File: LICENSE
Keywords: agents,langchain,ppx,preferences
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: langchain-core>=0.3.0
Requires-Dist: ppx-client>=0.1.0a1
Description-Content-Type: text/markdown

# ppx-langchain

> LangChain integration for the [Preference Profile Exchange (PPX)](https://blazing-customs.github.io/ppx-spec/).

## Install

```bash
pip install ppx-langchain
```

Requires Python 3.11+. Published version: **0.1.0a1** ([PyPI](https://pypi.org/project/ppx-langchain/)).

> Alpha, tracking a **draft** specification. Expect breaking changes.
> The version is `0.1.0a1` on PyPI and `0.1.0-alpha.1` on npm — the
> same release in each ecosystem's required format.

Pulls in `ppx-client` and `langchain-core`. No LangChain models are
required — bring your own (OpenAI, Anthropic, Ollama, etc.).

## Three ways to use PPX in a LangChain app

### 1. As a document loader — load claims once

```python
from ppx_client import PpxClient
from ppx_langchain import PpxClaimLoader

client = PpxClient("https://api.provider.app")
loader = PpxClaimLoader(client, user_token=my_keycloak_token)
docs = loader.load()  # one Document per claim
```

### 2. As a retriever — query claims per question

```python
from ppx_langchain import PpxRetriever

retriever = PpxRetriever(
    client=client,
    grant_token=my_grant_token,
    default_context={"climate": "hot_humid"},
    requested_namespaces=["core", "fragrance"],
)

docs = retriever.invoke("What scent profile suits this user?")
```

### 3. As a tool — let the agent call it

```python
from langchain_openai import ChatOpenAI
from ppx_langchain import ppx_preference_tool

llm = ChatOpenAI(model="gpt-4o-mini")
tool = ppx_preference_tool(client, grant_token=my_grant_token)
agent = llm.bind_tools([tool])

response = agent.invoke(
    "Recommend a fragrance. Use lookup_user_preference to check core + fragrance traits."
)
```

Every read is grant-scoped. The agent can never see claims the user's grant doesn't permit.

## License

Apache-2.0.
