Skip to content

Add langchain-dkg integration#4

Open
haroldboom wants to merge 1 commit intoOriginTrail:mainfrom
haroldboom:add/langchain-dkg
Open

Add langchain-dkg integration#4
haroldboom wants to merge 1 commit intoOriginTrail:mainfrom
haroldboom:add/langchain-dkg

Conversation

@haroldboom
Copy link
Copy Markdown

@haroldboom haroldboom commented Apr 28, 2026

Integration submission: langchain-dkg

Bounty tag: cfi-dkgv10-r1
Tier target: Flagship

What this is

LangChain memory and retriever components backed by OriginTrail DKG v10. Gives LangChain agents durable, verifiable, queryable memory — conversation history is stored as Knowledge Assets in Working Memory and retrieved via tri-modal search (vector + SPARQL + text).

Components

Class Purpose
DKGChatMessageHistory LangChain BaseChatMessageHistory backed by DKG WM
DKGMemory LCEL RunnableWithMessageHistory wrapper
DKGRetriever BaseRetriever using SPARQL SELECT against WM/SWM

Submission checklist

  • Entry file at integrations/langchain-dkg.json
  • Slug follows normalization rules (langchain-dkg)
  • install.kind is manual (Python library — pip install, not a CLI or service)
  • memoryLayers declared: WM (default), SWM (via explicit promote)
  • writeAuthority lists all mutating endpoints
  • Curator operation (POST /api/assertion/{name}/promote) explicitly declared and explained in security.notes
  • No external network egress (local DKG node only)
  • No postinstall/install/preinstall scripts in the published package
  • promotionPath filled in (WM → SWM → VM chain with UAL preservation)
  • designBrief linked
  • demo linked (interactive Colab notebook + video walkthrough)
  • 25/25 unit tests passing
  • MIT license consistent between registry entry and PyPI package
  • commit pinned to exact SHA

@haroldboom
Copy link
Copy Markdown
Author

Patch release 0.1.1 published.

While preparing for review I caught and fixed a few bugs in 0.1.0. The integration JSON in this PR is unaffected (no version pin), but anyone installing langchain-dkg via pip will now get the corrected build.

Fixes in v0.1.1:

  • DKGRetriever — read SPARQL JSON results under the "results" key (per W3C spec) and extract .value from each binding cell. The previous code silently returned 0 documents against real DKG responses.
  • DKGRetriever — escape SPARQL string literals to close a quote/backslash injection vector in the query argument.
  • DKGRetriever — sync _get_relevant_documents now works inside Jupyter / async servers (was RuntimeError: This event loop is already running); added the run_manager kwarg required by BaseRetriever; migrated to Pydantic v2 ConfigDict.
  • examples/research_agent.py — fixed an AttributeError (get_ualget_turn_uri).
  • DKGMemory — corrected docstring (.wrap.wrap_chain, layer values wm/swm).

PyPI: https://pypi.org/project/langchain-dkg/0.1.1/
Diff: haroldboom/dkg-langchain@v0.1.0...v0.1.1

All 25 unit tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant