Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
841149b
Initial Commit
dhirupandey Jun 27, 2025
fd0e466
Added documentation, license
dhirupandey Jul 25, 2025
d23ee15
Added ipynb documentation
dhirupandey Jul 25, 2025
211e797
Update coherence.ipynb
dhirupandey Jul 25, 2025
37ffcad
Update coherence.ipynb
dhirupandey Jul 25, 2025
4a0d8a7
Updates after review and added Makefile targets for publishing
dhirupandey Jul 25, 2025
09ca394
Merge branch 'langchain-ai:master' into master
dhirupandey Jul 25, 2025
b19010c
Merge branch 'langchain-ai:master' into master
dhirupandey Jul 28, 2025
6ca2bff
Updates for following the guidelines for notebook documentation
dhirupandey Jul 28, 2025
0bf2dba
Merge branch 'langchain-ai:master' into master
dhirupandey Jul 28, 2025
98fb660
Merge remote-tracking branch 'origin/master'
dhirupandey Jul 28, 2025
517c6c3
Merge branch 'langchain-ai:master' into master
dhirupandey Jul 29, 2025
fddd8d1
Force a re-run of PR github jobs
dhirupandey Jul 29, 2025
7b217ad
Merge branch 'langchain-ai:master' into master
dhirupandey Jul 31, 2025
b4a00fc
Updated pyproject.toml to conform to langchain's requirement enforced…
dhirupandey Jul 31, 2025
157fbcd
Fixes for CI breakages
dhirupandey Aug 1, 2025
eb5c949
Fixes for CI breakages
dhirupandey Aug 1, 2025
6477db9
Fixes for CI breakages
dhirupandey Aug 1, 2025
b42712b
Fixes for CI breakages
dhirupandey Aug 1, 2025
14cfcad
Fixes for CI breakages
dhirupandey Aug 1, 2025
a72bdf1
Fixes for CI breakages
dhirupandey Aug 1, 2025
d10cab0
Fixes for CI breakages
dhirupandey Aug 1, 2025
8272118
Fixes for CI breakages
dhirupandey Aug 1, 2025
ce62a71
Fixes for CI breakages
dhirupandey Aug 1, 2025
308f30f
Merge branch 'langchain-ai:master' into master
dhirupandey Aug 4, 2025
d29f8ef
Merge branch 'langchain-ai:master' into master
dhirupandey Aug 4, 2025
1c51f89
Merge branch 'langchain-ai:master' into master
dhirupandey Aug 6, 2025
cef7343
Merge branch 'master' into master
mdrxy Aug 11, 2025
054becb
Merge branch 'master' into master
mdrxy Aug 11, 2025
e82ec4d
Merge branch 'langchain-ai:master' into master
dhirupandey Aug 12, 2025
d95802f
Merge branch 'master' into master
mdrxy Sep 12, 2025
065062e
Merge branch 'master' into master
mdrxy Sep 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
396 changes: 396 additions & 0 deletions docs/docs/integrations/vectorstores/coherence.ipynb

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions libs/partners/coherence/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Python
__pycache__/
*.py[cod]
*.egg
*.egg-info/
dist/
build/
.eggs/

# Virtual environments
.venv/
.env/

# uv cache
.uv/

# Testing
htmlcov/
.cache/
.coverage
coverage.xml

# IDE
.idea/
.vscode/

# Logs
*.log

# OCA
.oca

# OS
.DS_Store
Thumbs.db

21 changes: 21 additions & 0 deletions libs/partners/coherence/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 LangChain, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
134 changes: 134 additions & 0 deletions libs/partners/coherence/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Makefile for LangChain-Coherence Integration
.PHONY: all format lint fix check lint_package lint_tests lint_diff format_diff integration_tests check_imports test tests install update-dev update-core lock sync

# ======================
# Environment Paths
# ======================
PYTHON := uv run python
PIP := uv pip
RUFF := uv run ruff
MYPY := uv run mypy
PYTEST := uv run pytest

# ======================
# Default
# ======================
all: help

# ======================
# Core Lint / Type Check
# ======================
lint: check

check:
@echo "🔍 Running linter and type checker..."
$(RUFF) check langchain_coherence tests
$(MYPY) --explicit-package-bases langchain_coherence

format:
@echo "🎨 Formatting Python code and docs notebooks..."
$(RUFF) format langchain_coherence tests ../../../docs/docs/integrations/vectorstores/coherence.ipynb

fix:
@echo "🔧 Fixing lint issues..."
$(MAKE) format
$(RUFF) check langchain_coherence tests ../../../docs/docs/integrations/vectorstores/coherence.ipynb --fix

# ======================
# New CI-Expected Lint Targets
# ======================
lint_package:
@echo "🔍 Linting package..."
$(RUFF) check langchain_coherence
$(MYPY) --explicit-package-bases langchain_coherence

lint_tests:
@echo "🔍 Linting tests..."
$(RUFF) check tests
$(MYPY) --explicit-package-bases tests

lint_diff:
@echo "🔍 Linting changed files..."
@changed_files=$$(git diff --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$' || true); \
if [ "$$changed_files" ]; then \
$(RUFF) check $$changed_files; \
else \
echo "No changed Python files."; \
fi

format_diff:
@echo "🎨 Formatting changed files..."
@changed_files=$$(git diff --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$' || true); \
if [ "$$changed_files" ]; then \
$(RUFF) format $$changed_files; \
else \
echo "No changed Python files."; \
fi

# ======================
# Import Checks
# ======================
check_imports:
@echo "🔍 Checking imports..."
$(PYTHON) ./scripts/check_imports.py

# ======================
# Testing
# ======================
test tests:
@if [ -d tests/unit_tests ] && [ "$$(find tests/unit_tests -type f -name 'test_*.py')" ]; then \
$(PYTEST) --disable-socket --allow-unix-socket tests/unit_tests; \
else \
echo "⚠️ No unit tests found — running all tests instead."; \
$(PYTEST) --disable-socket --allow-unix-socket tests; \
fi

integration_tests:
@echo "🧪 Running integration tests..."
$(PYTEST) tests/integration_tests

# ======================
# Dependency Management
# ======================
install:
@echo "🔧 Installing all dependencies..."
$(PIP) install -e . \
--group lint \
--group typing \
--group test \
--group docs \
--group publish

update-dev:
@echo "🔄 Updating development dependencies..."
$(PIP) install -e . \
--group lint \
--group typing \
--group test \
--group docs \
--group publish \
--upgrade

update-core:
@echo "🔄 Updating core dependencies..."
$(PIP) install --upgrade langchain-core coherence-client

lock:
@echo "🔐 Locking all dependencies to uv.lock..."
uv pip compile \
--group lint \
--group typing \
--group test \
--group docs \
--group publish

sync:
@echo "📦 Syncing dependencies from uv.lock..."
uv pip install -r uv.lock

# ======================
# Help
# ======================
help:
@echo "Available targets:"
@grep '^[a-zA-Z_-]\+:' Makefile | cut -d: -f1
103 changes: 103 additions & 0 deletions libs/partners/coherence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# LangChain Coherence Integration

This package integrates Oracle Coherence as a vector store in LangChain.

## Installation

```bash
pip install langchain_coherence
```

## Usage

Before using LangChain's CoherenceVectorStore you must ensure that a Coherence server ([Coherence CE](https://github.com/oracle/coherence) 25.03+ or [Oracle Coherence](https://www.oracle.com/java/coherence/) 14.1.2+) is running

For local development, we recommend using the Coherence CE container image:
```aiignore
docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:25.03.2
```

### Adding and retrieving Documents

```python
import asyncio

from langchain_coherence import CoherenceVectorStore
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
from langchain_huggingface.embeddings import HuggingFaceEmbeddings
from coherence import NamedMap, Session

async def do_run():
session: Session = await Session.create()
try:
named_map: NamedMap[str, Document] = await session.get_map("my-map")
embedding :Embeddings = HuggingFaceEmbeddings(
model_name="sentence-transformers/all-MiniLM-l6-v2")
# this embedding generates vectors of dimension 384
cvs :CoherenceVectorStore = await CoherenceVectorStore.create(
named_map,embedding)
d1 :Document = Document(id="1", page_content="apple")
d2 :Document = Document(id="2", page_content="orange")
documents = [d1, d2]
await cvs.aadd_documents(documents)

ids = [doc.id for doc in documents]
l = await cvs.aget_by_ids(ids)
assert len(l) == len(ids)
print("====")
for e in l:
print(e)
finally:
await session.close()

asyncio.run(do_run())
```
### SimilaritySearch on Documents

```python
from langchain_core.documents import Document
from langchain_core.embeddings import Embeddings
from langchain_huggingface.embeddings import HuggingFaceEmbeddings

from coherence import NamedMap, Session
from langchain_coherence import CoherenceVectorStore

def test_data():
d1 :Document = Document(id="1", page_content="apple")
d2 :Document = Document(id="2", page_content="orange")
d3 :Document = Document(id="3", page_content="tiger")
d4 :Document = Document(id="4", page_content="cat")
d5 :Document = Document(id="5", page_content="dog")
d6 :Document = Document(id="6", page_content="fox")
d7 :Document = Document(id="7", page_content="pear")
d8 :Document = Document(id="8", page_content="banana")
d9 :Document = Document(id="9", page_content="plum")
d10 :Document = Document(id="10", page_content="lion")

documents = [d1, d2, d3, d4, d5, d6, d7, d8, d9, d10]
return documents

async def test_asimilarity_search():
documents = test_data()
session: Session = await Session.create()
try:
named_map: NamedMap[str, Document] = await session.get_map("my-map")
embedding :Embeddings = HuggingFaceEmbeddings(
model_name="sentence-transformers/all-MiniLM-l6-v2")
# this embedding generates vectors of dimension 384
cvs :CoherenceVectorStore = await CoherenceVectorStore.create(
named_map,embedding)
await cvs.aadd_documents(documents)
ids = [doc.id for doc in documents]
l = await cvs.aget_by_ids(ids)
assert len(l) == 10

result = await cvs.asimilarity_search("fruit")
assert len(result) == 4
print("====")
for e in result:
print(e)
finally:
await session.close()
```
9 changes: 9 additions & 0 deletions libs/partners/coherence/langchain_coherence/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Public interface for the LangChain Coherence integration."""

from __future__ import annotations

__version__ = "0.0.3"

from langchain_coherence.coherence_store import CoherenceVectorStore

__all__ = ["CoherenceVectorStore"]
Loading
Loading