LangChain & AI Framework Integration โ
FLASH ships FlashLangChainAdapter โ a LangChain-style surface for encrypted vector storage and agent memory without exposing plaintext to the engine.
Installation โ
bash
npm install flash-zkQuick Start โ
javascript
import { FlashClient } from "flash-zk";
const client = new FlashClient({
storagePath: "./flash_data",
});
const adapter = client.langChainAdapter({
ragCollection: "my_knowledge",
memoryNamespace: "my_agent",
});
const vectorStore = adapter.asVectorStore();
const memory = adapter.asMemory();Vector Store โ
Compatible with LangChain-style addDocuments / similaritySearch:
javascript
await vectorStore.addDocuments([
{
pageContent: "FLASH is a server-blind encrypted intelligence database.",
metadata: { source: "docs" },
},
{
pageContent:
"Private RAG ingests client-side and searches by embedding similarity.",
metadata: { source: "docs" },
},
]);
const docs = await vectorStore.similaritySearch("server blind storage", 3);
console.log(docs.map((d) => d.pageContent));Under the hood: FlashPrivateRAG with encrypted ingest and HNSW search.
Conversation Memory โ
javascript
await memory.saveContext(
"What language does the user prefer?",
"The user prefers Arabic UI.",
);
const vars = await memory.loadMemoryVariables({
input: "language preference",
});
console.log(vars.history);Under the hood: FlashAgentMemory with semantic recall.
Wiring to LangChain (conceptual) โ
javascript
// Pseudocode โ adapt to your LangChain version
import { ChatOpenAI } from "@langchain/openai";
import { RetrievalQAChain } from "langchain/chains";
const llm = new ChatOpenAI({ model: "gpt-4o-mini" });
// Use FLASH vector store as retriever
const retriever = {
getRelevantDocuments: (q) => vectorStore.similaritySearch(q, 4),
};
// Chain: FLASH retrieves encrypted context โ LLM generates answer client-sideWARNING
The LLM call is your responsibility. FLASH retrieves context; it does not send data to OpenAI automatically.
Local LLM Pattern โ
Keep the full pipeline on-device:
Documents โ FLASH Private RAG (encrypted)
Question โ FLASH similaritySearch โ context chunks
Context โ Ollama / llama.cpp / local model โ answerNo cloud vector DB. No plaintext at rest on disk.
Engine Tuning for RAG Ingest โ
Bulk document ingest benefits from batch durability:
javascript
const client = new FlashClient({
storagePath: "./flash_data",
engineOptions: {
durability: "balanced",
},
});
// Prefer batch inserts when loading many chunks
await client.collection("chunks").insertMany(docs);