next.tsx


Overview

The next.tsx file defines a React functional component named RetrievalForm that renders a complex, configurable retrieval form interface. This form is used to configure parameters for a retrieval-based operation, likely in an AI or knowledge base query system. It integrates multiple specialized form fields and UI components such as query input, knowledge base selection, similarity sliders, reranking options, and multi-language support.

The form leverages React Hook Form for state management and validation, with Zod schemas for type-safe validation. It supports advanced settings in a collapsible UI section, allowing users to customize parameters like similarity thresholds, top-N results, reranking strategies, and empty response text.

The file also exports a reusable EmptyResponseField subcomponent for entering fallback text when no retrieval results are found.

Finally, the file exports the RetrievalForm component wrapped with React.memo for performance optimization.


Exports

1. RetrievalPartialSchema


2. FormSchema


3. EmptyResponseField

Example usage:

<Form>
  ...
  <EmptyResponseField />
  ...
</Form>

4. RetrievalForm

Usage example:

import RetrievalForm from './next';

function MyApp() {
  const node = { id: 'node1', ...otherProps };

  return <RetrievalForm node={node} />;
}

Implementation Details and Algorithms


Interaction With Other Parts of the System


Component Structure Diagram

componentDiagram
    direction TB
    component RetrievalForm {
      +node: INextOperatorForm
      +form: useForm()
      +outputList: Array
      +useWatchFormChange()
      +Render Form & Fields
    }
    component EmptyResponseField {
      +Uses useFormContext()
      +Renders Textarea for empty_response
    }
    component RAGFlowFormItem
    component KnowledgeBaseFormField
    component SimilaritySliderFormField
    component TopNFormField
    component RerankFormFields
    component CrossLanguageFormField
    component UseKnowledgeGraphFormField
    component Collapse
    component Output
    component PromptEditor
    component FormWrapper
    component FormContainer

    RetrievalForm --> RAGFlowFormItem
    RetrievalForm --> KnowledgeBaseFormField
    RetrievalForm --> Collapse
    Collapse --> SimilaritySliderFormField
    Collapse --> TopNFormField
    Collapse --> RerankFormFields
    Collapse --> EmptyResponseField
    Collapse --> CrossLanguageFormField
    Collapse --> UseKnowledgeGraphFormField
    RetrievalForm --> Output
    RAGFlowFormItem --> PromptEditor
    RetrievalForm --> FormWrapper
    FormWrapper --> FormContainer
    FormContainer --> KnowledgeBaseFormField
    FormContainer --> SimilaritySliderFormField
    FormContainer --> TopNFormField

Summary

The next.tsx file implements a highly modular and configurable retrieval form for an advanced query or knowledge base system. It provides a clean separation of concerns by composing domain-specific form fields and UI components, backed by strong validation and internationalization support. The form supports both simple inputs and advanced, collapsible settings, making it suitable for both novice and power users. Its design ensures easy integration with the larger system through props, hooks, and output structures.