0.0.0-alpha.4 • Published 5 months ago

@aichatkit/localstorage-adapter v0.0.0-alpha.4

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

@aichatkit/localstorage-adapter

LocalStorage implementation of the storage adapter for Hypermode ChatKit.

Installation

npm install @aichatkit/localstorage-adapter

Usage

import { LocalStorageAdapter } from '@aichatkit/localstorage-adapter';
import { ChatInterface } from '@aichatkit/ui';

// Create and initialize the adapter
const storageAdapter = new LocalStorageAdapter({
  // Optional custom configuration
  conversationPrefix: 'my-app-chat_',
  conversationIdsKey: 'my-app-conversation-ids',
  activeConversationKey: 'my-app-active-conversation'
});

// Initialize the adapter
await storageAdapter.initialize();

// Use with ChatInterface
function ChatApp() {
  return (
    <ChatInterface
      storageAdapter={storageAdapter}
      // other props...
    />
  );
}

Configuration Options

The LocalStorageAdapter constructor accepts an optional configuration object with the following properties:

  • conversationPrefix: Key prefix for conversations in localStorage (default: 'chatkitconversation')
  • conversationIdsKey: Key for storing the list of conversation IDs (default: 'chatkit_conversation_ids')
  • activeConversationKey: Key for storing the active conversation ID (default: 'chatkit_active_conversation')

License

MIT © Hypermode