Skip to content

Commit

Permalink
feat: boolean parameter use checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
Aralhi committed Jan 3, 2024
1 parent 6963584 commit de644e3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions web/components/knowledge/strategy-form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IChunkStrategyResponse } from '@/types/knowledge';
import { Alert, Form, FormListFieldData, Input, InputNumber, Radio, RadioChangeEvent } from 'antd';
import { Alert, Checkbox, Form, FormListFieldData, Input, InputNumber, Radio, RadioChangeEvent } from 'antd';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
const { TextArea } = Input;
Expand Down Expand Up @@ -54,13 +54,25 @@ export default function StrategyForm({ strategies, docType, fileName, field }: I
name={[field!.name, 'chunk_parameters', param.param_name]}
rules={[{ required: true, message: t('Please_input_the_name') }]}
initialValue={param.default_value}
valuePropName={param.param_type === 'boolean' ? 'checked' : 'value'}
>
{param.param_type === 'int' ? <InputNumber className="w-full" min={1} /> : <TextArea className="w-full" rows={2} maxLength={6} />}
{renderParamByType(param.param_type)}
</Form.Item>
))}
</div>
);
}

function renderParamByType(type: string) {
switch (type) {
case 'int':
return <InputNumber className="w-full" min={1} />;
case 'string':
return <TextArea className="w-full" rows={2} />;
case 'boolean':
return <Checkbox />;
}
}
return (
<>
<Form.Item name={[field!.name, 'chunk_parameters', 'chunk_strategy']} initialValue={DEFAULT_STRATEGY.strategy}>
Expand Down

0 comments on commit de644e3

Please sign in to comment.