Skip to main content

Overview

This example demonstrates a basic chat implementation using HAI Protocol with WebSocket transport. We will be asking the LLM to act as a pirate and respond to the user.

Server Implementation

Usage Example

Run the server:
We will be using the CLI to interact with this tool.

Key Features

Real-time Messaging

WebSocket transport for instant bidirectional communication with low latency.

Message Streaming

Support for message start/part/end events for streaming large content.

Session Management

Unique session IDs for managing multiple concurrent connections.

Sequence Numbering

Automatic sequence numbering for maintaining message order and detecting duplicates.

Event-Driven Architecture

Extensible event system for handling different message types and custom events.

Protocol Compliance

Full HAIP v1.1.2 specification compliance with all required handshake and messaging events.
This example provides a foundation for building more complex chat applications with HAI Protocol.