npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dialogai/ydb-chat-history

v2.0.2

Published

YDB (Yandex Database) chat message history implementation for LangChain applications

Readme

@dialogai/ydb-chat-history

YDB (Yandex Database) chat message history implementation for LangChain applications.

Installation

npm install @dialogai/ydb-chat-history

Description

This module provides a chat message history implementation for LangChain that uses YDB (Yandex Database) as the storage backend. It extends the BaseListChatMessageHistory class from @langchain/core/chat_history and provides methods for storing, retrieving, and managing chat messages in YDB.

Features

  • 🗂️ Store and retrieve chat messages in YDB
  • 🔒 Read-only mode support
  • 💾 Backup and restore functionality
  • 🔄 Compatible with LangChain ecosystem
  • 📝 TypeScript support
  • ⚡ Efficient message handling

Usage

const { YdbChatMessageHistory } = require('@dialogai/ydb-chat-history');
const { HumanMessage, AIMessage } = require('@langchain/core/messages');

// Option 1: Direct database path specification
const chatHistory1 = new YdbChatMessageHistory({
  sessionId: 'user-session-123',
  database: '/ru-central1/b1g..../etn...', // YDB database path
  table_name: 'chat_history_db', // optional, defaults to 'chat_history_db'
  readOnly: false // optional, defaults to false
});

// Option 2: Using environment variables
// Set CHAT_HISTORY_DB_ADDRESS or YDB_ADDRESS environment variable
const chatHistory2 = new YdbChatMessageHistory({
  sessionId: 'user-session-456'
  // database path will be taken from environment variables
});

// Add a message using LangChain BaseMessage objects
await chatHistory1.addMessage(new HumanMessage('Hello, how are you?'));

// Add AI response
await chatHistory1.addMessage(new AIMessage('I am doing well, thank you!'));

// Get all messages (returns BaseMessage[] array)
const messages = await chatHistory1.getMessages();
console.log(messages);

// Add multiple messages
await chatHistory1.addMessages([
  new HumanMessage('First message'),
  new AIMessage('Second message')
]);

// Create backup
await chatHistory1.backup();

// Restore from backup
await chatHistory1.restore();

// Clear all messages
await chatHistory1.clear();

Configuration

The constructor accepts the following options:

  • sessionId (required): Unique identifier for the chat session
  • database (optional): YDB database path (e.g., /ru-central1/b1g..../etn...). See database connection priority below
  • table_name (optional): Name of the table to store chat history. Defaults to chat_history_db
  • readOnly (optional): If true, prevents adding new messages. Defaults to false

Database Connection Priority

The YDB database address is determined in the following priority order:

  1. Constructor database field - Direct specification in the constructor
  2. CHAT_HISTORY_DB_ADDRESS environment variable - Fallback environment variable
  3. YDB_ADDRESS environment variable - Global YDB address environment variable
  4. Error - If none of the above are specified, an error will occur

Database Requirements

The target YDB database must contain a table for storing chat message history. By default, the table name is chat_history_db, but it can be customized using the table_name parameter in the constructor.

Environment Variables

  • CHAT_HISTORY_DB_ADDRESS: YDB database address (higher priority)
  • YDB_ADDRESS: Global YDB database address (lower priority)

Dependencies

  • @dieugene/key-value-db: YDB key-value database client
  • @langchain/core: LangChain core library (peer dependency)

License

ISC

Author

Eugene Ditkovsky

Contributing

Issues and pull requests are welcome on GitHub.