-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 tag_kwd parameter to chunk configuration modal #4368 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
Showing
13 changed files
with
204 additions
and
13 deletions.
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
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
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
101 changes: 101 additions & 0 deletions
101
web/src/pages/add-knowledge/components/knowledge-setting/tag-item.tsx
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,101 @@ | ||
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks'; | ||
import { UserOutlined } from '@ant-design/icons'; | ||
import { | ||
Avatar, | ||
Divider, | ||
Flex, | ||
Form, | ||
InputNumber, | ||
Select, | ||
Slider, | ||
Space, | ||
} from 'antd'; | ||
import DOMPurify from 'dompurify'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
export const TagSetItem = () => { | ||
const { t } = useTranslation(); | ||
|
||
const { list: knowledgeList } = useFetchKnowledgeList(true); | ||
|
||
const knowledgeOptions = knowledgeList | ||
.filter((x) => x.parser_id === 'tag') | ||
.map((x) => ({ | ||
label: ( | ||
<Space> | ||
<Avatar size={20} icon={<UserOutlined />} src={x.avatar} /> | ||
{x.name} | ||
</Space> | ||
), | ||
value: x.id, | ||
})); | ||
|
||
return ( | ||
<Form.Item | ||
label={t('knowledgeConfiguration.tagSet')} | ||
name={['parser_config', 'tag_kb_ids']} | ||
tooltip={ | ||
<div | ||
dangerouslySetInnerHTML={{ | ||
__html: DOMPurify.sanitize(t('knowledgeConfiguration.tagSetTip')), | ||
}} | ||
></div> | ||
} | ||
rules={[ | ||
{ | ||
message: t('chat.knowledgeBasesMessage'), | ||
type: 'array', | ||
}, | ||
]} | ||
> | ||
<Select | ||
mode="multiple" | ||
options={knowledgeOptions} | ||
placeholder={t('chat.knowledgeBasesMessage')} | ||
></Select> | ||
</Form.Item> | ||
); | ||
}; | ||
|
||
export const TopNTagsItem = () => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Form.Item label={t('knowledgeConfiguration.topnTags')}> | ||
<Flex gap={20} align="center"> | ||
<Flex flex={1}> | ||
<Form.Item | ||
name={['parser_config', 'topn_tags']} | ||
noStyle | ||
initialValue={3} | ||
> | ||
<Slider max={10} min={1} style={{ width: '100%' }} /> | ||
</Form.Item> | ||
</Flex> | ||
<Form.Item name={['parser_config', 'topn_tags']} noStyle> | ||
<InputNumber max={10} min={1} /> | ||
</Form.Item> | ||
</Flex> | ||
</Form.Item> | ||
); | ||
}; | ||
|
||
export function TagItems() { | ||
return ( | ||
<> | ||
<Divider /> | ||
<TagSetItem></TagSetItem> | ||
<Form.Item noStyle dependencies={[['parser_config', 'tag_kb_ids']]}> | ||
{({ getFieldValue }) => { | ||
const ids: string[] = getFieldValue(['parser_config', 'tag_kb_ids']); | ||
|
||
return ( | ||
Array.isArray(ids) && | ||
ids.length > 0 && <TopNTagsItem></TopNTagsItem> | ||
); | ||
}} | ||
</Form.Item> | ||
<Divider /> | ||
</> | ||
); | ||
} |
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
Oops, something went wrong.