0.0.0-alpha.4 • Published 5 months ago
@aichatkit/network-adapter v0.0.0-alpha.4
@aichatkit/network-adapter
Base network adapter abstract class for Hypermode ChatKit.
Installation
npm install @aichatkit/network-adapterUsage
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
0.0.0-alpha.4
5 months ago
0.0.0-alpha.3
5 months ago
0.0.0-alpha.2
5 months ago
0.0.0-alpha.1
5 months ago
0.0.0-alpha.0
5 months ago