Eunomia SDK for LangChain
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Eunomia SDK for LangChain
This package provides integrations between LangChain and Eunomia, allowing you to:
- Register documents loaded by any LangChain's loader to the Eunomia server
- Enforce authorization policies on documents retrieved by any LangChain retriever
Installation
Install the eunomia-sdk-langchain package via pip:
pip install eunomia-sdk-langchain
Usage
Document Loader
The EunomiaLoader class is a wrapper around any loader class from LangChain that sends documents to the Eunomia server.
from eunomia_sdk_langchain import EunomiaLoader
from langchain_community.document_loaders.csv_loader import CSVLoader
# Create a document loader
loader = CSVLoader("data.csv")
# Wrap the loader with Eunomia
wrapped_loader = EunomiaLoader(loader)
# Load documents and register them with the Eunomia server
docs = wrapped_loader.load(additional_metadata={"group": "financials"})
All loaded documents will be automatically sent to the Eunomia server which will assign an identifier to each document and store their metadata. The identifiers and metadata can then be used to configure or reference policies in the Eunomia server.
Document Retriever
The EunomiaRetriever class wraps any LangChain retriever and filters allowed documents using the Eunomia server.
from eunomia_core import schemas
from eunomia_sdk_langchain import EunomiaRetriever
from langchain_community.retrievers import BM25Retriever
from langchain_core.documents import Document
# Create a retriever with some documents
retriever = BM25Retriever.from_documents([
Document(page_content="foo", metadata={"confidentiality": "public"}),
Document(page_content="bar", metadata={"confidentiality": "public"}),
Document(page_content="foo bar", metadata={"confidentiality": "private"}),
])
# Wrap the retriever with Eunomia
wrapped_retriever = EunomiaRetriever(
retriever=retriever,
principal=schemas.PrincipalCheck(uri="test-uri"),
)
# Only documents the principal has access to will be returned
docs = wrapped_retriever.invoke("foo")
Documentation
For detailed usage, check out the SDK's documentation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eunomia_sdk_langchain-0.3.2.tar.gz.
File metadata
- Download URL: eunomia_sdk_langchain-0.3.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e815204cc47b8541d69e57ff7fe2e2d432afa88e3dba012e90e94a1d1a32725
|
|
| MD5 |
b4761ba973887c0d2e8963a5d6efe9f3
|
|
| BLAKE2b-256 |
edf27369ff99bc8fb5b40439e3b06f76892d7fdb216825c16c6743881ef1fd69
|
File details
Details for the file eunomia_sdk_langchain-0.3.2-py3-none-any.whl.
File metadata
- Download URL: eunomia_sdk_langchain-0.3.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fb71a04261bbe0f965ec14d3eacd7bf35f3e8bece1259b249923f57e2098af7
|
|
| MD5 |
e5bbcc7cff5b73fa05e6600743ccfc27
|
|
| BLAKE2b-256 |
b3d887fd7bf1294fc81434517d4acd5d98462e63409af3e919796e4c9d28caf0
|