LangChain.js Integration

The @dakera-ai/langchain package provides LangChain.js components backed by Dakera — persistent agent memory and server-side vector search for TypeScript applications.

Quick Start

npm install @dakera-ai/langchain

Requires Node.js ≥ 18 and a running Dakera server.

import { DakeraMemory, DakeraVectorStore } from "@dakera-ai/langchain";

const memory = new DakeraMemory({
  apiUrl: "http://localhost:3300",
  apiKey: "dk-mykey",
  agentId: "my-agent",
});

const vectorstore = new DakeraVectorStore({
  apiUrl: "http://localhost:3300",
  apiKey: "dk-mykey",
  namespace: "my-docs",
});

Features

Examples

Conversation chain with persistent memory

import { ChatOpenAI } from "@langchain/openai";
import { ConversationChain } from "langchain/chains";
import { DakeraMemory } from "@dakera-ai/langchain";

const memory = new DakeraMemory({
  apiUrl: "http://localhost:3300",
  apiKey: "dk-mykey",
  agentId: "chat-agent",
  recallK: 5,
  importance: 0.7,
});

const chain = new ConversationChain({
  llm: new ChatOpenAI({ model: "gpt-4o" }),
  memory,
});

const res = await chain.call({ input: "My name is Alice." });

// Later — memory persists across restarts
const res2 = await chain.call({ input: "What's my name?" });

RAG retriever

import { DakeraVectorStore } from "@dakera-ai/langchain";

const vectorstore = new DakeraVectorStore({
  apiUrl: "http://localhost:3300",
  apiKey: "dk-mykey",
  namespace: "my-docs",
});

// Add documents
await vectorstore.addDocuments([
  { pageContent: "Dakera handles embeddings server-side.", metadata: {} },
  { pageContent: "Memory decay removes stale data automatically.", metadata: {} },
]);

// Retrieve
const retriever = vectorstore.asRetriever({ k: 4 });
const docs = await retriever.getRelevantDocuments("How does Dakera embed?");

Session management

import { DakeraSessionManager } from "@dakera-ai/langchain";

const sessions = new DakeraSessionManager({
  apiUrl: "http://localhost:3300",
  apiKey: "dk-mykey",
  agentId: "my-agent",
});

const session = await sessions.start({ metadata: { user: "alice" } });
// ... use session.id with memory operations ...
await sessions.end(session.id, "Completed onboarding flow");

API Reference

DakeraMemory options

ParameterTypeDefaultDescription
apiUrlstringDakera server URL
apiKeystring""API key
agentIdstringAgent identifier for memory namespacing
recallKnumber5Memories to surface per turn
importancenumber0.7Importance assigned to stored memories
memoryKeystring"history"Key injected into the prompt

DakeraVectorStore options

ParameterTypeDefaultDescription
apiUrlstringDakera server URL
apiKeystring""API key
namespacestringVector namespace to read/write

Configuration

DAKERA_API_URL=http://localhost:3300
DAKERA_API_KEY=dk-your-key

Set these in your .env file. The client reads them when constructor options are not passed explicitly.

Links