balibabu
commited on
Commit
·
60101af
1
Parent(s):
71b7e06
feat: set the object-fit attribute of the chunk image to contain so that the image is not stretched and if the chunk number of the knowledge base is greater than 0, set the embedding model to disabled (#160)
Browse files* feat: if the chunk number of the knowledge base is greater than 0, set the embedding model to disabled
* feat: set the object-fit attribute of the chunk image to contain so that the image is not stretched
- web/src/components/max-token-number.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-card/index.less +4 -2
- web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-card/index.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx +3 -2
- web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts +5 -3
- web/src/pages/chat/chat-container/index.less +6 -2
- web/src/pages/chat/chat-container/index.tsx +1 -1
web/src/components/max-token-number.tsx
CHANGED
@@ -3,7 +3,7 @@ import { Flex, Form, InputNumber, Slider } from 'antd';
|
|
3 |
const MaxTokenNumber = () => {
|
4 |
return (
|
5 |
<Form.Item
|
6 |
-
label="
|
7 |
tooltip="It determine the token number of a chunk approximately."
|
8 |
>
|
9 |
<Flex gap={20} align="center">
|
|
|
3 |
const MaxTokenNumber = () => {
|
4 |
return (
|
5 |
<Form.Item
|
6 |
+
label="Chunk token number"
|
7 |
tooltip="It determine the token number of a chunk approximately."
|
8 |
>
|
9 |
<Flex gap={20} align="center">
|
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-card/index.less
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
.image {
|
2 |
width: 100px !important;
|
3 |
-
|
4 |
}
|
5 |
|
6 |
.imagePreview {
|
7 |
-
width:
|
|
|
|
|
8 |
}
|
9 |
|
10 |
.content {
|
|
|
1 |
.image {
|
2 |
width: 100px !important;
|
3 |
+
object-fit: contain;
|
4 |
}
|
5 |
|
6 |
.imagePreview {
|
7 |
+
max-width: 50vw;
|
8 |
+
max-height: 50vh;
|
9 |
+
object-fit: contain;
|
10 |
}
|
11 |
|
12 |
.content {
|
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-card/index.tsx
CHANGED
@@ -55,7 +55,7 @@ const ChunkCard = ({
|
|
55 |
<Checkbox onChange={handleCheck} checked={checked}></Checkbox>
|
56 |
{item.img_id && (
|
57 |
<Popover
|
58 |
-
placement="
|
59 |
content={
|
60 |
<Image id={item.img_id} className={styles.imagePreview}></Image>
|
61 |
}
|
|
|
55 |
<Checkbox onChange={handleCheck} checked={checked}></Checkbox>
|
56 |
{item.img_id && (
|
57 |
<Popover
|
58 |
+
placement="right"
|
59 |
content={
|
60 |
<Image id={item.img_id} className={styles.imagePreview}></Image>
|
61 |
}
|
web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx
CHANGED
@@ -15,7 +15,7 @@ const { Option } = Select;
|
|
15 |
const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
16 |
const { submitKnowledgeConfiguration, submitLoading } =
|
17 |
useSubmitKnowledgeConfiguration();
|
18 |
-
const { parserList, embeddingModelOptions } =
|
19 |
useFetchKnowledgeConfigurationOnMount(form);
|
20 |
|
21 |
const onFinishFailed = (errorInfo: any) => {
|
@@ -90,6 +90,7 @@ const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
|
90 |
<Select
|
91 |
placeholder="Please select a embedding model"
|
92 |
options={embeddingModelOptions}
|
|
|
93 |
></Select>
|
94 |
</Form.Item>
|
95 |
<Form.Item
|
@@ -98,7 +99,7 @@ const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
|
98 |
tooltip="The instruction is at right."
|
99 |
rules={[{ required: true }]}
|
100 |
>
|
101 |
-
<Select placeholder="Please select a chunk method">
|
102 |
{parserList.map((x) => (
|
103 |
<Option value={x.value} key={x.value}>
|
104 |
{x.label}
|
|
|
15 |
const ConfigurationForm = ({ form }: { form: FormInstance }) => {
|
16 |
const { submitKnowledgeConfiguration, submitLoading } =
|
17 |
useSubmitKnowledgeConfiguration();
|
18 |
+
const { parserList, embeddingModelOptions, disabled } =
|
19 |
useFetchKnowledgeConfigurationOnMount(form);
|
20 |
|
21 |
const onFinishFailed = (errorInfo: any) => {
|
|
|
90 |
<Select
|
91 |
placeholder="Please select a embedding model"
|
92 |
options={embeddingModelOptions}
|
93 |
+
disabled={disabled}
|
94 |
></Select>
|
95 |
</Form.Item>
|
96 |
<Form.Item
|
|
|
99 |
tooltip="The instruction is at right."
|
100 |
rules={[{ required: true }]}
|
101 |
>
|
102 |
+
<Select placeholder="Please select a chunk method" disabled={disabled}>
|
103 |
{parserList.map((x) => (
|
104 |
<Option value={x.value} key={x.value}>
|
105 |
{x.label}
|
web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts
CHANGED
@@ -41,8 +41,6 @@ export const useSubmitKnowledgeConfiguration = () => {
|
|
41 |
};
|
42 |
|
43 |
export const useFetchKnowledgeConfigurationOnMount = (form: FormInstance) => {
|
44 |
-
// const [form] = Form.useForm();
|
45 |
-
|
46 |
const knowledgeDetails = useSelectKnowledgeDetails();
|
47 |
const parserList = useSelectParserList();
|
48 |
const embeddingModelOptions = useSelectLlmOptions();
|
@@ -69,7 +67,11 @@ export const useFetchKnowledgeConfigurationOnMount = (form: FormInstance) => {
|
|
69 |
});
|
70 |
}, [form, knowledgeDetails]);
|
71 |
|
72 |
-
return {
|
|
|
|
|
|
|
|
|
73 |
};
|
74 |
|
75 |
export const useSelectKnowledgeDetailsLoading = () =>
|
|
|
41 |
};
|
42 |
|
43 |
export const useFetchKnowledgeConfigurationOnMount = (form: FormInstance) => {
|
|
|
|
|
44 |
const knowledgeDetails = useSelectKnowledgeDetails();
|
45 |
const parserList = useSelectParserList();
|
46 |
const embeddingModelOptions = useSelectLlmOptions();
|
|
|
67 |
});
|
68 |
}, [form, knowledgeDetails]);
|
69 |
|
70 |
+
return {
|
71 |
+
parserList,
|
72 |
+
embeddingModelOptions,
|
73 |
+
disabled: knowledgeDetails.chunk_num > 0,
|
74 |
+
};
|
75 |
};
|
76 |
|
77 |
export const useSelectKnowledgeDetailsLoading = () =>
|
web/src/pages/chat/chat-container/index.less
CHANGED
@@ -47,16 +47,20 @@
|
|
47 |
}
|
48 |
|
49 |
.referencePopoverWrapper {
|
50 |
-
width: 50vw;
|
51 |
}
|
52 |
|
53 |
.referenceChunkImage {
|
54 |
width: 10vw;
|
|
|
55 |
}
|
56 |
|
57 |
.referenceImagePreview {
|
58 |
-
width:
|
|
|
59 |
}
|
60 |
.chunkContentText {
|
61 |
.chunkText;
|
|
|
|
|
62 |
}
|
|
|
47 |
}
|
48 |
|
49 |
.referencePopoverWrapper {
|
50 |
+
max-width: 50vw;
|
51 |
}
|
52 |
|
53 |
.referenceChunkImage {
|
54 |
width: 10vw;
|
55 |
+
object-fit: contain;
|
56 |
}
|
57 |
|
58 |
.referenceImagePreview {
|
59 |
+
max-width: 45vw;
|
60 |
+
max-height: 45vh;
|
61 |
}
|
62 |
.chunkContentText {
|
63 |
.chunkText;
|
64 |
+
max-height: 45vh;
|
65 |
+
overflow-y: auto;
|
66 |
}
|
web/src/pages/chat/chat-container/index.tsx
CHANGED
@@ -95,7 +95,7 @@ const MessageItem = ({
|
|
95 |
className={styles.referencePopoverWrapper}
|
96 |
>
|
97 |
<Popover
|
98 |
-
placement="
|
99 |
content={
|
100 |
<Image
|
101 |
id={chunkItem?.img_id}
|
|
|
95 |
className={styles.referencePopoverWrapper}
|
96 |
>
|
97 |
<Popover
|
98 |
+
placement="left"
|
99 |
content={
|
100 |
<Image
|
101 |
id={chunkItem?.img_id}
|