balibabu
commited on
Commit
·
b6e253d
1
Parent(s):
0dec4cf
Feat: Add question parameter to edit chunk modal #3873 (#3874)
Browse files### What problem does this PR solve?
Feat: Add question parameter to edit chunk modal #3873
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/locales/en.ts
CHANGED
@@ -325,6 +325,7 @@ When you want to search the given knowledge base at first place, set a higher pa
|
|
325 |
ellipse: 'Ellipse',
|
326 |
graph: 'Knowledge graph',
|
327 |
mind: 'Mind map',
|
|
|
328 |
},
|
329 |
chat: {
|
330 |
newConversation: 'New conversation',
|
|
|
325 |
ellipse: 'Ellipse',
|
326 |
graph: 'Knowledge graph',
|
327 |
mind: 'Mind map',
|
328 |
+
question: 'Question',
|
329 |
},
|
330 |
chat: {
|
331 |
newConversation: 'New conversation',
|
web/src/locales/zh-traditional.ts
CHANGED
@@ -309,6 +309,7 @@ export default {
|
|
309 |
ellipse: '省略',
|
310 |
graph: '知識圖譜',
|
311 |
mind: '心智圖',
|
|
|
312 |
},
|
313 |
chat: {
|
314 |
newConversation: '新會話',
|
|
|
309 |
ellipse: '省略',
|
310 |
graph: '知識圖譜',
|
311 |
mind: '心智圖',
|
312 |
+
question: '問題',
|
313 |
},
|
314 |
chat: {
|
315 |
newConversation: '新會話',
|
web/src/locales/zh.ts
CHANGED
@@ -326,6 +326,7 @@ export default {
|
|
326 |
ellipse: '省略',
|
327 |
graph: '知识图谱',
|
328 |
mind: '思维导图',
|
|
|
329 |
},
|
330 |
chat: {
|
331 |
newConversation: '新会话',
|
|
|
326 |
ellipse: '省略',
|
327 |
graph: '知识图谱',
|
328 |
mind: '思维导图',
|
329 |
+
question: '问题',
|
330 |
},
|
331 |
chat: {
|
332 |
newConversation: '新会话',
|
web/src/pages/add-knowledge/components/knowledge-chunk/components/chunk-creating-modal/index.tsx
CHANGED
@@ -25,6 +25,7 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
|
|
25 |
const [form] = Form.useForm();
|
26 |
const [checked, setChecked] = useState(false);
|
27 |
const [keywords, setKeywords] = useState<string[]>([]);
|
|
|
28 |
const { removeChunk } = useDeleteChunkByIds();
|
29 |
const { data } = useFetchChunk(chunkId);
|
30 |
const { t } = useTranslation();
|
@@ -35,14 +36,17 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
|
|
35 |
content_with_weight,
|
36 |
important_kwd = [],
|
37 |
available_int,
|
|
|
38 |
} = data.data;
|
39 |
form.setFieldsValue({ content: content_with_weight });
|
40 |
setKeywords(important_kwd);
|
|
|
41 |
setChecked(available_int === 1);
|
42 |
}
|
43 |
|
44 |
if (!chunkId) {
|
45 |
setKeywords([]);
|
|
|
46 |
form.setFieldsValue({ content: undefined });
|
47 |
}
|
48 |
}, [data, form, chunkId]);
|
@@ -53,6 +57,7 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
|
|
53 |
onOk?.({
|
54 |
content: values.content,
|
55 |
keywords, // keywords
|
|
|
56 |
available_int: checked ? 1 : 0, // available_int
|
57 |
});
|
58 |
} catch (errorInfo) {
|
@@ -91,6 +96,10 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
|
|
91 |
<p className="mb-2">{t('chunk.keyword')} *</p>
|
92 |
<EditTag tags={keywords} setTags={setKeywords} />
|
93 |
</section>
|
|
|
|
|
|
|
|
|
94 |
{chunkId && (
|
95 |
<section>
|
96 |
<Divider></Divider>
|
|
|
25 |
const [form] = Form.useForm();
|
26 |
const [checked, setChecked] = useState(false);
|
27 |
const [keywords, setKeywords] = useState<string[]>([]);
|
28 |
+
const [question, setQuestion] = useState<string[]>([]);
|
29 |
const { removeChunk } = useDeleteChunkByIds();
|
30 |
const { data } = useFetchChunk(chunkId);
|
31 |
const { t } = useTranslation();
|
|
|
36 |
content_with_weight,
|
37 |
important_kwd = [],
|
38 |
available_int,
|
39 |
+
question_kwd = [],
|
40 |
} = data.data;
|
41 |
form.setFieldsValue({ content: content_with_weight });
|
42 |
setKeywords(important_kwd);
|
43 |
+
setQuestion(question_kwd);
|
44 |
setChecked(available_int === 1);
|
45 |
}
|
46 |
|
47 |
if (!chunkId) {
|
48 |
setKeywords([]);
|
49 |
+
setQuestion([]);
|
50 |
form.setFieldsValue({ content: undefined });
|
51 |
}
|
52 |
}, [data, form, chunkId]);
|
|
|
57 |
onOk?.({
|
58 |
content: values.content,
|
59 |
keywords, // keywords
|
60 |
+
question_kwd: question,
|
61 |
available_int: checked ? 1 : 0, // available_int
|
62 |
});
|
63 |
} catch (errorInfo) {
|
|
|
96 |
<p className="mb-2">{t('chunk.keyword')} *</p>
|
97 |
<EditTag tags={keywords} setTags={setKeywords} />
|
98 |
</section>
|
99 |
+
<section className="pt-2">
|
100 |
+
<p className="mb-2">{t('chunk.question')} *</p>
|
101 |
+
<EditTag tags={question} setTags={setQuestion} />
|
102 |
+
</section>
|
103 |
{chunkId && (
|
104 |
<section>
|
105 |
<Divider></Divider>
|
web/src/pages/add-knowledge/components/knowledge-chunk/hooks.ts
CHANGED
@@ -99,10 +99,12 @@ export const useUpdateChunk = () => {
|
|
99 |
content,
|
100 |
keywords,
|
101 |
available_int,
|
|
|
102 |
}: {
|
103 |
content: string;
|
104 |
keywords: string;
|
105 |
available_int: number;
|
|
|
106 |
}) => {
|
107 |
const code = await createChunk({
|
108 |
content_with_weight: content,
|
@@ -110,6 +112,7 @@ export const useUpdateChunk = () => {
|
|
110 |
chunk_id: chunkId,
|
111 |
important_kwd: keywords, // keywords
|
112 |
available_int,
|
|
|
113 |
});
|
114 |
|
115 |
if (code === 0) {
|
|
|
99 |
content,
|
100 |
keywords,
|
101 |
available_int,
|
102 |
+
question_kwd,
|
103 |
}: {
|
104 |
content: string;
|
105 |
keywords: string;
|
106 |
available_int: number;
|
107 |
+
question_kwd: string;
|
108 |
}) => {
|
109 |
const code = await createChunk({
|
110 |
content_with_weight: content,
|
|
|
112 |
chunk_id: chunkId,
|
113 |
important_kwd: keywords, // keywords
|
114 |
available_int,
|
115 |
+
question_kwd,
|
116 |
});
|
117 |
|
118 |
if (code === 0) {
|