genai_prototype/README.md
Standalone prototype demonstrating the GenAI module architecture for ProxySQL.
This prototype demonstrates a thread-pool based GenAI module that:
┌─────────────────────────────────────────────────────────┐
│ GenAI Module │
│ │
│ ┌────────────────────────────────────────────────┐ │
│ │ Listener Thread (epoll-based) │ │
│ │ - Monitors all client file descriptors │ │
│ │ - Reads incoming requests │ │
│ │ - Pushes to request queue │ │
│ └──────────────────┬─────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────────────────────────────┐ │
│ │ Request Queue │ │
│ │ - Thread-safe queue │ │
│ │ - Condition variable for worker notification │ │
│ └──────────────────┬─────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────────────────────────────┐ │
│ │ Thread Pool (configurable number of workers) │ │
│ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ │
│ │ │Worker│ │Worker│ │Worker│ │Worker│ ... │ │
│ │ └───┬──┘ └───┬──┘ └───┬──┘ └───┬──┘ │ │
│ │ └──────────┴──────────┴──────────┘ │ │
│ └────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
▲ │ ▲
│ │ │
socketpair() Responses socketpair()
from clients to clients from clients
Client → GenAI (Request):
struct RequestHeader {
uint64_t request_id; // Client's correlation ID
uint32_t operation; // 0=embedding, 1=completion, 2=rag
uint32_t input_size; // Size of following data
uint32_t flags; // Reserved
};
// Followed by input_size bytes of input data
GenAI → Client (Response):
struct ResponseHeader {
uint64_t request_id; // Echo client's ID
uint32_t status_code; // 0=success, >0=error
uint32_t output_size; // Size of following data
uint32_t processing_time_ms; // Time taken to process
};
// Followed by output_size bytes of output data
# Build
make
# Run
make run
# Clean
make clean
# Debug build
make debug
# Show help
make help
Implemented:
TODO (Enhancement Phase):
Phase 1: Prototype Enhancement (Current)
Phase 2: ProxySQL Integration
Phase 3: Production Features