Metadata-Version: 2.5
Name: langchain-serenedb
Version: 26.9.3
Summary: An integration package connecting SereneDB and LangChain
Project-URL: Homepage, https://serenedb.com
Project-URL: Repository, https://github.com/serenedb/langchain-serenedb
Project-URL: Documentation, https://docs.serenedb.com
Author: SereneDB
License-Expression: MIT
License-File: LICENSE
Keywords: embeddings,langchain,postgres,psycopg,rag,serenedb,vector-database,vectorstore
Classifier: Intended Audience :: Developers
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: Topic :: Database
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: langchain-core<2.0,>=1.2.11
Requires-Dist: numpy<3,>=1.21
Requires-Dist: psycopg-pool<4,>=3.2.1
Requires-Dist: psycopg[binary]<4,>=3
Provides-Extra: test
Requires-Dist: langchain-tests>=1.1.5; extra == 'test'
Requires-Dist: mypy>=1.15.0; extra == 'test'
Requires-Dist: pytest-asyncio>=0.25.3; extra == 'test'
Requires-Dist: pytest-cov>=6.0.0; extra == 'test'
Requires-Dist: pytest-mock>=3.14.0; extra == 'test'
Requires-Dist: pytest-timeout>=2.3.1; extra == 'test'
Requires-Dist: pytest>=8.3.4; extra == 'test'
Requires-Dist: ruff>=0.9.7; extra == 'test'
Description-Content-Type: text/markdown

# langchain-serenedb

A [LangChain](https://python.langchain.com/) vector store integration for
[SereneDB](https://serenedb.com)

SereneDB speaks the PostgreSQL wire protocol, so this package connects with **psycopg3**.
It maps the integration onto SereneDB's native capabilities:

| Vector Store Search Feature | SereneDB Feature used |
|---|---|
| Vector column |  `FLOAT[N]`  |
| Distance ops | `<->`, `<=>`, `<#>`, `<+>` |
| ANN index |  inverted index on the vector column e.g. `USING inverted (emb ivf (metric='cosine', ...))` |
| Full-text |  inverted index on the text column + `BM25(idx.tableoid)` |
| Metadata | `JSON` column, explicit columns |

## Installation

```bash
pip install langchain-serenedb
```

Requires Python 3.10+.

## Quickstart (engine + table)

```python
from langchain_serenedb import SereneDBEngine, IVFIndex

engine = SereneDBEngine.from_connection_string(
    "host=127.0.0.1 port=7890 user=postgres dbname=postgres"
)

# Table only (vector search falls back to an exact scan until an index is built):
engine.init_vectorstore_table(table_name="my_docs", vector_size=768)

# Or create the table and its IVF ANN index in one call, so vector search is
# accelerated from the start:
engine.init_vectorstore_table("my_docs", 768, vector_index=IVFIndex())
#   ...or the combined full-text + vector index for hybrid search:
#   engine.init_vectorstore_table("my_docs", 768, hybrid_search_config=HybridSearchConfig())

# ... after writing rows, publish them to the inverted index:
engine.refresh_table("my_docs")
```

> **Tip:** for a large bulk load, SereneDB trains better IVF clusters if you create the
> index *after* loading (`store.apply_vector_index(IVFIndex())`); creating it up front
> with the table is the convenient choice for incremental workloads.

## Contributing

Building, testing, linting, and running the suite (locally or in Docker Compose) are
covered in [CONTRIBUTING.md](CONTRIBUTING.md).

## License

MIT
