Implementation:Infiniflow Ragflow Logic Hooks
| Knowledge Sources | |
|---|---|
| Domains | Frontend, React_Hooks, Chat |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Concrete collection of core React hooks for chat message handling, SSE streaming, document operations, and LLM interactions used across the RAGFlow frontend.
Description
The logic-hooks.ts module provides approximately 15 hooks covering: SSE-based message streaming (useFetchNextConversation), chat message management, document preview handling, LLM model option building, knowledge base operations, and conversation state management. These hooks form the primary business logic layer for the chat and conversation subsystem.
Usage
Import individual hooks when building chat views, conversation panels, or any component that needs to interact with the RAGFlow chat/conversation API via Server-Sent Events.
Code Reference
Source Location
- Repository: Infiniflow_Ragflow
- File: web/src/hooks/logic-hooks.ts
- Lines: 1-800
Signature
// Key hooks (representative)
export function useFetchNextConversation(): { ... };
export function useSendMessageWithSse(conversationId: string): { ... };
export function useSelectLlmOptionsByModelType(): OptionType[];
export function useGetDocumentUrl(): (docId: string) => string;
Import
import { useFetchNextConversation, useSelectLlmOptionsByModelType } from '@/hooks/logic-hooks';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| conversationId | string | Varies | Conversation ID for message hooks |
Outputs
| Name | Type | Description |
|---|---|---|
| Hook return values | various | State, callbacks, and derived data |
Usage Examples
import { useSelectLlmOptionsByModelType } from '@/hooks/logic-hooks';
function ModelSelector() {
const options = useSelectLlmOptionsByModelType();
return <Select options={options} />;
}