Skip to content

Latest commit

 

History

History

langchain

Folders and files

README.md

langchain-openviking

Working memory is now opt-in. Update installed plugins separately from the OV server, then restart the host. Existing explicit settings still take precedence. See the default-off upgrade guide for native history, re-enabling WM, and old-conversation handoffs.

langchain-openviking is the official OpenViking integration package for LangChain and LangGraph applications. It keeps framework-specific adapters separate from the OpenViking server and communicates with remote OpenViking instances through the lightweight openviking-sdk package.

OpenViking Server requirement: examples here use the viking://~ home alias (for example viking://~/memories), which the server expands to the authenticated caller's own user space, so they require a server with viking://~ support. The uid-less viking://user/memories shorthand is rejected by newer servers; pass an explicit viking://user/<uid>/... URI when targeting another user.

Installation

For LangChain retrievers, tools, message history, and context wrappers:

pip install langchain-openviking

For the LangGraph store and middleware:

pip install "langchain-openviking[langgraph]"

Quick start

from langchain_openviking import OpenVikingRetriever
from openviking_sdk import SyncHTTPClient

client = SyncHTTPClient(
    url="http://127.0.0.1:1933",
    api_key="your-user-api-key",
    auth_mode="api_key",
)
client.initialize()
retriever = OpenVikingRetriever(
    client=client,
    target_uri="viking://~/memories",
)

try:
    documents = retriever.invoke("What deployment preferences should I remember?")
finally:
    client.close()

For API-key-only integrations, pass auth_mode="api_key" alongside api_key. The authentication mode is forwarded to owned synchronous and asynchronous SDK clients, including clients rebuilt during safe-read recovery. Leaving it unset preserves the SDK's existing configuration defaults. The same option is available on the recorder, retriever, message history, store, tools, and context wrappers.

The package also provides OpenVikingSessionRecorder, OpenVikingContextMiddleware, OpenVikingStore, OpenVikingChatMessageHistory, and create_openviking_tools.

create_openviking_tools includes viking_rule_search in the retrieval, agent, and admin profiles. Pass task_context and optionally rule_probability_threshold (default 0.65) to check compiled constraints before an action or response. It returns the full rendered Rules without truncation. Use an SDK client exposing rule_search and a server with POST /api/v1/rules/search; an error must not be treated as no applicable Rules.

Client ownership

  • A client supplied through client= or async_client= remains caller-owned.
  • Clients created from url= are managed by the adapter and can be closed with close() or aclose() as documented by each adapter.

Import migration

Starting with the next server release after v0.5.0, the legacy openviking.integrations.langchain namespace is removed without a compatibility shim. v0.5.0 still provides it. Install the standalone package and import from langchain_openviking instead; see the Unreleased migration notes.

from langchain_openviking import OpenVikingRetriever

See the OpenViking documentation, examples, and the framework adapter guide.

Validate

From the repository root:

pip install -e 'integrations/frameworks/langchain[langgraph,test,dev]'
python -m pytest -q --noconftest -o addopts='' \
  integrations/frameworks/langchain/tests tests/unit/test_langchain_package_boundary.py

Package metadata and source headers declare AGPL-3.0; see LICENSE. The runnable examples retain Apache-2.0.