Documentation Index
Fetch the complete documentation index at: https://rag-docs.peakfs.io/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Our React Chat Client Components allows you to embed a fully interactive chat interface into any React application. Built with React components and hooks, this SDK manages chat functionality - including thread creation, message handling, and chart data display - providing a flexible way to implement AI-assisted chat features.Key Components and Hooks
Messages Component
Displays the chat history, showing user and assistant messages. The component can also render charts and other visual data elements alongside messages if configured. Properties:messages(MessageInterface[]): Array of messages in the chat conversation.MessageInterface:id(string): Unique identifier for each message.role(‘user’ | ‘assistant’ | ‘system’): Role of the message sender.content(string): The message content, typically in markdown format.ragThreadId(string): Thread ID for session tracking.createdAt(string): Timestamp indicating when the message was created.meta(optional):chart: Contains data for charts associated with the message.dataset(string): JSON string representing chart data.chartType(string): Type of chart (e.g., pie, line, column).
chartDataMap(React.ReactNode): A map of chart data nodes, keyed by message ID, allowing dynamic chart rendering within the chat.
ChatForm Component
Provides a simple input field and submission button for user messages, making it easy for users to send messages to the assistant. Properties:onSubmit((message: string) => void): Callback function that handles the message submission when the user sends a message.isLoading(boolean): Disables the input field and submit button when set to true, indicating that a message is being processed.
useChatThread Hook
The useChatThread hook manages the chat thread’s state, creating a new thread if needed and persisting it with LocalStorage. This hook also handles message submission and manages responses from the assistant. Properties:createThread: Function to initialize a new chat thread and return its ID.loadMessages: Function to load messages for an existing thread.fetchLastAssistantMessage: Function to fetch the last message from the assistant.sendMessage: Function to send a message in the current thread.
messages: Array of chat messages in the thread.setMessages: Function to update the messages state.isLoading: Indicates if a message is currently being processed.handleSubmit: Handles message submission.ragThreadId: The unique thread ID for the current chat session.
useChartData
The useChartData hook dynamically generates and displays charts based on message metadata. It uses chartType to determine the chart style (pie, column, or line) and maps the rendered chart to the corresponding message ID. Parameters:messages: Array of chat messages, each containing optional metadata for chart rendering.chartDataMap: A map of rendered charts keyed by message ID.setChartDataMap: Function to update chartDataMap when a new chart is rendered.