feat: LangChain integration for Python SDK - #69
Merged
Merged
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
jsam
added a commit
that referenced
this pull request
Sep 4, 2026
* chore(deps): resolve every open Dependabot alert across npm and pip manifests 131 open alerts, six manifests, all npm or pip (no Cargo alerts). front: next 16.2.1 -> 16.2.11, postcss ^8.5.23; nanoid and sharp via audit fix. demo: hono ^4.12.34, ws ^8.21.0, nodemailer ^6 -> ^9 (createTransport and sendMail are unchanged); esbuild and follow-redirects via update. inputlayer-js: ws ^8.21.0; vite, vitest, postcss, nanoid, picomatch via update; esbuild pinned to ^0.28.1 through an override because tsup's range still admits the vulnerable line. api-client: orval ^8.5 -> ^8.22 (two import-time RCEs and an SSRF); fast-uri, js-yaml, linkify-it, markdown-it, brace-expansion, picomatch via update; same esbuild override. inputlayer-py: idna, langchain-core, langchain-openai, langgraph-checkpoint, langgraph-sdk, langsmith, pytest, urllib3 relocked. langsmith's patched line needs websockets >= 15, so the bound widens to >=13,<16; the client already imports websockets.asyncio.client, which is the API that survives. Removed docs/site: a Nextra 2 skeleton with no pages directory and no lockfile, last touched in #69, referenced by nothing in CI or the Makefile (the live site is front/). It carried 15 Next.js 13 advisories no build would ever exercise. Removed packages/api-client/bun.lock: out of sync with package-lock.json, and nothing installs with bun. Verified: npm audit reports 0 vulnerabilities in all four npm packages; front builds; demo builds; inputlayer-js typechecks, builds, and passes 96 unit tests under Node 22; api-client builds; inputlayer-py passes 974 unit tests. * fix(deps): exact Next pin, targeted lockfiles, docs README after review - front: Next pinned exactly at 16.3.4 (was loosened to a caret). 16.2.11 closes the Next advisories but vendors postcss 8.5.22 and depends on sharp 0.34, both still flagged; 16.3.x is the first line where the vendored copies are patched, and it is what the earlier build actually ran against. - demo, inputlayer-js, api-client: lockfiles rebuilt from main with only the flagged packages moved. Drops the unrelated @types/node 25 -> 26 and zod 3 -> 4 majors that a blanket npm update had swept in. Remaining majors are what the bumped packages themselves require (commander for orval 8.27) or were the alert (picomatch 2 -> 4). - demo: esbuild override, same reason as the other two (tsx's range still admits the vulnerable line). - vite in inputlayer-js resolved under Node 22: npm's engine check on Node 21 silently refused to move it past 7.3.1. - docs/README.md and .gitignore no longer mention the removed docs/site. Verified from clean installs: npm ci passes in all four packages; front builds; demo builds; inputlayer-js typechecks, builds, 96 tests pass under Node 22; api-client typechecks and builds; npm audit is 0 everywhere.
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.
LangChain integration for the Python SDK
This PR adds first-class LangChain support to the Python client, letting you plug an InputLayer knowledge graph into any LangChain chain, agent, or pipeline with a few lines of code.
What's included
Integration components (
src/inputlayer/integrations/langchain/)InputLayerRetriever- aBaseRetrieverwith two modes. IQL mode gives full query control with safe:placeholderparameter binding. Vector mode auto-detects theVectorcolumn on a Relation, embeds the user query, and ranks by distance - all composed as IQL under the hood.InputLayerVectorStore- a fullVectorStoreimplementation that maps a typed Relation schema to LangChain'sadd_texts/similarity_search/delete/ MMR interface.tools_from_relations- generates oneStructuredToolper Relation with a typed Pydantic args schema derived from the relation's scalar columns. The LLM never writes IQL; it picks structured arguments and the tool builds the query.InputLayerIQLTool- escape hatch for agents that need to run raw IQL.bind_params/iql_literal- safe parameter binding that prevents IQL injection.Sync/async bridge (
src/inputlayer/_sync.py)Replaces the old
run_until_completepattern with a dedicated background event loop thread (same pattern as httpx). The sync client now works inside Jupyter, FastAPI, LangGraph, and any context with an already-running event loop.17 examples
The examples are designed to show patterns that only become possible when you combine an LLM with a reasoning engine. Each one runs against a real InputLayer server - no mocks.
InputLayerRetrieverwith anarticle JOIN user_interestquery and safe:inputplaceholder bindingtools_from_relationsgenerates typed tools an agent can call without writing IQLretriever | prompt | llm | parserpipeline, drop-in compatible with LangChain compositionVectorStore.aadd_textsembeds and persists them.why()returns structured proof trees alongside results so the LLM can cite specific base facts;.why_not()explains absent resultsreports_to); the LLM reads pre-computed derived facts instead of doing graph traversal itselfgrounded_claimandhallucinated_claimsetsmulti_sourced(2+ sources confirm) andconflict(same subject, different values)Running the examples
Usage
Other changes
Python langchain integration (live server)workflowdocs/content/docs/guides/langchain.mdxConnectionError/PermissionErrorrenamed toInputLayerConnectionError/InputLayerPermissionError(old names kept as aliases) to avoid shadowing Python builtinsQueryErrorexport: now available from the top-level packageValueErrorinstead of silently defaulting to cosineTest plan
uv run pytest tests/test_sync.py- 44 sync bridge testsuv run pytest tests/test_langchain.py- 119 LangChain integration tests (unit) + 5 live server testsuv run pytest tests/test_compiler.py- 59 compiler tests