index.tsx


Overview

This file, index.tsx, defines a React functional component named ParseConfiguration used in a knowledge configuration context. The component renders a dynamic form interface that allows users to configure parser options, specifically for a parser type referred to as "raptor". It includes various controls such as switches, sliders, input numbers, and text areas to customize parsing behavior.

Additionally, the file exports utility constants and functions that determine whether certain parser configurations or UI elements should be displayed, based on the type of document parser selected.

Key features of the file:


Exported Constants and Functions

excludedParseMethods: DocumentParserType[]

An array listing document parser types for which the "raptor" parse configuration should not be shown.


showRaptorParseConfiguration(parserId: DocumentParserType | undefined): boolean

Determines whether the "raptor" parse configuration UI should be shown for a given parser ID.


excludedTagParseMethods: DocumentParserType[]

An array listing document parser types for which tag items should not be shown.


showTagItems(parserId: DocumentParserType): boolean

Determines whether tag items should be displayed for a given parser ID.


Component: ParseConfiguration

Description

ParseConfiguration is a React functional component that renders a form section dedicated to configuring the "raptor" parser settings. It integrates with Ant Design's form system (Form.useFormInstance()) and a translation hook (useTranslate) for localization.

The form includes controls to enable or disable the raptor parser and, when enabled, display and manipulate various parameters such as prompts, token limits, thresholds, cluster sizes, and random seed values.

Usage

This component is intended to be used within a larger form managing document parser configurations. It conditionally shows fields depending on whether the "raptor" parser is enabled.

import ParseConfiguration from './index.tsx';

// Inside a parent form
<Form>
  {/* Other form items */}
  <ParseConfiguration />
</Form>

Internal Methods

handleGenerate()

Rendered Form Items

Field Name

Description

UI Control Type

Validation

Initial Value

Tooltip

parser_config.raptor.use_raptor

Toggle to enable/disable raptor parser

Switch

None

false

Translated "useRaptorTip"

parser_config.raptor.prompt

Text prompt for the parser

TextArea

Required

Translated "promptText"

Translated "promptTip"

parser_config.raptor.max_token

Maximum token count

Slider + InputNumber

Required, max 2048

256

Translated "maxTokenTip"

parser_config.raptor.threshold

Threshold value (range 0-1)

Slider + InputNumber

Required, [0,1] with step 0.01

0.1

Translated "thresholdTip"

parser_config.raptor.max_cluster

Maximum cluster count

Slider + InputNumber

Required, 1 to 1024

64

Translated "maxClusterTip"

parser_config.raptor.random_seed

Seed for randomization

InputNumber + Button

Required

0

N/A

Important Implementation Details


Interaction with Other Parts of the System

This component and utilities are likely used in a larger document parser configuration page or modal, where the user selects a parser type and configures its parameters.


Visual Diagram

componentDiagram
    direction TB

    component ParseConfiguration {
        +handleGenerate()
        +render()
    }

    component Form {
        +useFormInstance()
    }

    component Localization {
        +useTranslate()
    }

    component AntdComponents {
        +Switch
        +Slider
        +InputNumber
        +Input.TextArea
        +Button
        +Form.Item
    }

    component Utility {
        +random()
    }

    ParseConfiguration --> Form : uses
    ParseConfiguration --> Localization : uses
    ParseConfiguration --> AntdComponents : renders UI controls
    ParseConfiguration --> Utility : calls random() for seed generation

Summary

This file is a focused configuration component and related utilities to support dynamic display of parser options in a knowledge/document parsing system.