Quickest way to production grade RAG UI.
Documentation β’ Blog
Lexio is a powerful React library for building Retrieval-Augmented Generation (RAG) interfaces, handling complex workflows out of the box while remaining simple to use and highly customizable.
It supports multiple document types (PDF, HTML, Markdown, Text) with advanced features like streaming responses, source highlighting, and a comprehensive state management system.
Developers can use ready-made components or easily build custom ones using React hooks and the flexible action handler pattern.
You can install the library with npm or yarn:
npm install lexio
To use the GUI components, you need to provide an action handler to the LexioProvider
context:
import {
LexioProvider,
ChatWindow,
AdvancedQueryField,
SourcesDisplay,
ContentDisplay,
ErrorDisplay
} from 'lexio';
const App = () => (
<LexioProvider
onAction={(action, messages, sources, activeSources, selectedSource) => {
// Handle user messages
if (action.type === 'ADD_USER_MESSAGE') {
return {
// Return sources as a Promise that resolves to Source[]
sources: Promise.resolve([
{
title: "Example Document",
type: "pdf",
relevance: 0.95,
metadata: {
author: "Documentation Team",
page: 3
}
}
]),
// Return a response as a Promise or use streaming
response: Promise.resolve("This is a sample response based on the retrieved documents.")
};
}
// Handle source selection
if (action.type === 'SET_SELECTED_SOURCE' && action.sourceObject) {
return {
sourceData: fetchSourceContent(action.sourceObject.id)
};
}
return undefined;
}}
config={{
timeouts: {
request: 30000, // 30 seconds for entire operations
stream: 5000 // 5 seconds between stream chunks
}
}}
>
<div className="flex flex-col h-screen">
<div className="flex-1">
<ChatWindow markdown={true} />
</div>
<div>
<AdvancedQueryField />
</div>
<div className="flex">
<SourcesDisplay />
<ContentDisplay />
</div>
</div>
<ErrorDisplay />
</LexioProvider>
);
Follow the documentation to learn more about the library.
The LexioProvider is the core component that provides the context for all Lexio UI components:
- It manages the shared state for all UI components
- It processes user actions through the
onAction
ActionHandler - It handles error states and loading indicators
- It provides configuration options for timeouts and other settings
Lexio provides several ready-to-use UI components:
- ChatWindow: π¬ Displays the conversation history and AI responses with markdown support
- AdvancedQueryField: π Input field for user messages with optional advanced features
- SourcesDisplay: π Shows retrieved sources with metadata and selection capabilities
- ContentDisplay: π Renders the content of selected sources with highlighting
- ErrorDisplay: β Shows error messages and loading states
Lexio provides a set of React hooks that allow you to interact with the state and trigger actions from your custom components:
- useSources: π Access and manipulate source-related state
- useMessages: π Access and manipulate message-related state
- useStatus: β³ Access loading and error states
Pre-built components for chat interfaces, source selection, and document viewing with highlighting
Transparent state handling for seamless interaction between components
- Enterprise-grade reliability
- Seamless integration with existing systems
- Production-ready components
- Professional support options