0.0.0-alpha.4 • Published 5 months ago

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

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

@aichatkit/network-adapter

Base network adapter abstract class for Hypermode ChatKit.

Installation

npm install @aichatkit/network-adapter

Usage

This package provides the base abstract class for implementing network adapters. You typically won't use this package directly, but rather create or use an implementation like @aichatkit/apollo-adapter.

import { NetworkAdapter } from '@aichatkit/network-adapter';
import { Message } from '@aichatkit/types';

// Example: Create a custom adapter implementation
class CustomNetworkAdapter extends NetworkAdapter {
  async sendMessage(message: string, conversationId: string, history?: string): Promise<Message> {
    // Implement your custom network logic here
    const response = await fetch('https://your-api.com/chat', {
      method: 'POST',
      body: JSON.stringify({ message, conversationId, history }),
      headers: { 'Content-Type': 'application/json' },
    });

    const data = await response.json();

    return {
      id: Date.now(),
      content: data.message,
      role: 'assistant',
      timestamp: new Date().toISOString(),
    };
  }
}

License

MIT © Hypermode