Open
Conversation
… wrapper The old sync wrapper crashed inside running event loops (Jupyter, FastAPI, LangGraph). Uses a dedicated daemon thread with its own loop instead — same pattern as httpx. Prerequisite for LangChain integration.
InputLayerRetriever supports raw Datalog queries with {input} placeholder
and vector search mode. InputLayerTool exposes KG queries to LangChain agents.
Both provide native async and sync paths via the run_sync bridge.
…diction detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
InputLayerVectorStore — LangChain VectorStore interface
Summary
Adds
InputLayerVectorStore, a LangChainVectorStoreimplementation backed by InputLayer. This makes InputLayer a drop-in replacement for Chroma, Pinecone, Weaviate, FAISS, etc. in any existing LangChain RAG tutorial or chain — change the import, keep the code.Why this matters
LangChain's
VectorStoreis the most common abstraction in the LangChain ecosystem. Hundreds of tutorials, courses, and example projects assume you have aVectorStore. Until now, those flowed past InputLayer because we only offered a customRetriever. With this PR, everyVectorStoretutorial works with InputLayer by changing one import.What's new
InputLayerVectorStoreintegrations/langchain/vectorstore.pyVectorStoreimplementation with sync + async pathsImplemented methods
from_texts(classmethod, required)afrom_textsadd_texts(with UUIDs, metadata, explicit ids)aadd_textsadd_documentsaadd_documentssimilarity_search(required)asimilarity_searchsimilarity_search_by_vectorasimilarity_search_by_vectorsimilarity_search_with_scoreasimilarity_search_with_scoreget_by_idsaget_by_idsdelete(by ids)adeleteas_retriever()All sync methods go through the
run_syncbridge, so they work safely in Jupyter, FastAPI, LangGraph, and any running event loop.Usage
How it stores data
A single relation per instance:
id— UUID by default, user-provided ids supportedcontent— the document textmetadata— JSON-encoded for arbitrary structureembedding— the dense vector from the embeddings modelDistance is computed via InputLayer's
cosine/euclidean/dot/manhattanfunctions in a Datalog query.Tests
27 unit tests (
tests/test_vectorstore.py) using a mock KG with realistic Datalog parsing:Example
examples/langchain/ex18_vectorstore.py— end-to-end demo:from_texts— bulk-load 6 documents with metadatasimilarity_search— find most similar docs to a querysimilarity_search_with_score— show distancesas_retriever— wrap as a LangChain retrieverretriever → prompt → llm(when LM Studio is available)Falls back to deterministic fake embeddings when no LLM server is running, so the example always works for demos and CI.
Files changed
src/inputlayer/integrations/langchain/vectorstore.py— new (~330 lines)src/inputlayer/integrations/langchain/__init__.py— exportInputLayerVectorStoretests/test_vectorstore.py— new (27 tests)examples/langchain/ex18_vectorstore.py— newexamples/langchain/runner.py— register example test: hardening and comprehensive regression tests #18Test plan
uv run pytest tests/test_vectorstore.py -v— 27 unit testsuv run python -m examples.langchain.ex18_vectorstore— runs against a server, demonstrates full lifecycleuv run python -m examples.langchain.runner 18— runs via the runnerDesign notes
InputLayerVectorStoreinstance maps to one relation. To use multiple collections, instantiate the store multiple times with differentcollection_namevalues.kg.vector_search()with HNSW indexes for large collections (~100K+ documents). For typical RAG corpora (1K-10K documents) the scan is fast enough.