-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### What problem does this PR solve? feat: Add delimiter field to naive parsing method #1909 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
Showing
6 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Form, Input } from 'antd'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface IProps { | ||
value?: string | undefined; | ||
onChange?: (val: string | undefined) => void; | ||
} | ||
|
||
const DelimiterInput = ({ value, onChange }: IProps) => { | ||
const nextValue = value?.replaceAll('\n', '\\n'); | ||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const val = e.target.value; | ||
const nextValue = val.replaceAll('\\n', '\n'); | ||
onChange?.(nextValue); | ||
}; | ||
return <Input value={nextValue} onChange={handleInputChange}></Input>; | ||
}; | ||
|
||
const Delimiter = () => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Form.Item | ||
name={['parser_config', 'delimiter']} | ||
label={t('knowledgeDetails.delimiter')} | ||
initialValue={`\\n!?;。;!?`} | ||
rules={[{ required: true }]} | ||
> | ||
<DelimiterInput /> | ||
</Form.Item> | ||
); | ||
}; | ||
|
||
export default Delimiter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters