Skip to content

Dakera-AI/dakera-langchain-js

@dakera-ai/langchain

CI npm Downloads Node License: MIT dakera.ai Docs Docs

LangChain.js integration for Dakera — persistent semantic memory and server-side vector search, no local embedding model required.

Class Description
DakeraMemory Drop-in BaseMemory for LangChain.js conversation chains
DakeraVectorStore VectorStore backed by Dakera's server-side embedding engine

Quick Start

Step 1 — Run Dakera

Dakera is a self-hosted memory server. Spin it up with Docker:

docker run -d \
  --name dakera \
  -p 3300:3300 \
  -e DAKERA_ROOT_API_KEY=dk-mykey \
  ghcr.io/dakera-ai/dakera:latest

For a production setup with persistent storage, use Docker Compose:

curl -sSfL https://raw.githubusercontent.com/Dakera-AI/dakera-deploy/main/docker-compose.yml \
  -o docker-compose.yml
DAKERA_API_KEY=dk-mykey docker compose up -d

curl http://localhost:3300/health  # → {"status":"ok"}

Full deployment guide: github.com/Dakera-AI/dakera-deploy

Step 2 — Install the integration

npm install @dakera-ai/langchain @dakera-ai/dakera @langchain/core

Step 3 — Use it

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

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

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

// Memory persists across sessions and restarts
const response = await chain.call({ input: "My project is called NeuralBridge." });
console.log(response.response);

Installation

npm install @dakera-ai/langchain @dakera-ai/dakera @langchain/core

Requirements: Node.js ≥ 20, a running Dakera server (see Step 1 above)


DakeraMemory

Persistent conversation memory for LangChain.js chains. Stores and recalls conversation history using Dakera's hybrid search.

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

const memory = new DakeraMemory({
  apiUrl: "http://localhost:3300",
  apiKey: process.env.DAKERA_API_KEY!,
  agentId: "my-agent",
  recallK: 5,       // how many past memories to surface per turn
  importance: 0.7,  // importance score for stored memories
});

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

// First session
await chain.call({ input: "My name is Alice and I'm building a chatbot." });

// Later session — memory persists across restarts
const { response } = await chain.call({ input: "What was I building?" });
console.log(response); // "You mentioned you were building a chatbot."

Options

Option Type Default Description
apiUrl string Dakera server URL (e.g. http://localhost:3300)
apiKey string "" Dakera API key
agentId string Agent identifier for memory namespacing
recallK number 5 Number of memories to recall per turn
minImportance number 0 Minimum importance threshold for recall
memoryKey string "history" Key injected into the chain prompt
inputKey string first key Input key used as recall query
importance number 0.7 Importance score assigned to stored memories

DakeraVectorStore

Server-side embedded vector store for RAG. Dakera handles embeddings — no local model, no OpenAI embeddings API needed.

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

const vectorstore = new DakeraVectorStore({
  apiUrl: "http://localhost:3300",
  apiKey: process.env.DAKERA_API_KEY!,
  namespace: "my-docs",
});

// Index documents (server handles embedding)
await vectorstore.addDocuments([
  { pageContent: "Dakera is a persistent memory platform for AI agents.", metadata: { source: "docs" } },
  { pageContent: "It supports Python, JavaScript, Rust, and Go SDKs.", metadata: { source: "docs" } },
]);

// Semantic search
const results = await vectorstore.similaritySearch("What languages are supported?", 4);
console.log(results[0].pageContent);

RAG chain

import { RetrievalQAChain } from "langchain/chains";
import { ChatOpenAI } from "@langchain/openai";
import { DakeraVectorStore } from "@dakera-ai/langchain";

const vectorstore = new DakeraVectorStore({
  apiUrl: "http://localhost:3300",
  apiKey: process.env.DAKERA_API_KEY!,
  namespace: "my-docs",
});

const chain = RetrievalQAChain.fromLLM(
  new ChatOpenAI({ model: "gpt-4o" }),
  vectorstore.asRetriever({ k: 4 }),
);

const { text } = await chain.call({ query: "How does memory decay work?" });
console.log(text);

From texts (LangChain convention)

const store = await DakeraVectorStore.fromTexts(
  ["Document one content", "Document two content"],
  [{ source: "a" }, { source: "b" }],
  null, // embeddings param — unused, Dakera handles server-side embedding
  { apiUrl: "http://localhost:3300", apiKey: "dk-mykey", namespace: "docs" },
);

Options

Option Type Default Description
apiUrl string Dakera server URL
apiKey string "" Dakera API key
namespace string Vector namespace to read/write
embeddingModel string namespace default Server-side embedding model override

Related packages

Package Framework Language
langchain-dakera LangChain Python
crewai-dakera CrewAI Python
llamaindex-dakera LlamaIndex Python
autogen-dakera AutoGen Python

Links


License

MIT © Dakera AI


About

LangChain.js integration for Dakera AI memory — dakera.ai

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors