Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add question parameter to edit chunk modal #3873 #3874

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ When you want to search the given knowledge base at first place, set a higher pa
ellipse: 'Ellipse',
graph: 'Knowledge graph',
mind: 'Mind map',
question: 'Question',
},
chat: {
newConversation: 'New conversation',
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/zh-traditional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ export default {
ellipse: '省略',
graph: '知識圖譜',
mind: '心智圖',
question: '問題',
},
chat: {
newConversation: '新會話',
Expand Down
1 change: 1 addition & 0 deletions web/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export default {
ellipse: '省略',
graph: '知识图谱',
mind: '思维导图',
question: '问题',
},
chat: {
newConversation: '新会话',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
const [form] = Form.useForm();
const [checked, setChecked] = useState(false);
const [keywords, setKeywords] = useState<string[]>([]);
const [question, setQuestion] = useState<string[]>([]);
const { removeChunk } = useDeleteChunkByIds();
const { data } = useFetchChunk(chunkId);
const { t } = useTranslation();
Expand All @@ -35,14 +36,17 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
content_with_weight,
important_kwd = [],
available_int,
question_kwd = [],
} = data.data;
form.setFieldsValue({ content: content_with_weight });
setKeywords(important_kwd);
setQuestion(question_kwd);
setChecked(available_int === 1);
}

if (!chunkId) {
setKeywords([]);
setQuestion([]);
form.setFieldsValue({ content: undefined });
}
}, [data, form, chunkId]);
Expand All @@ -53,6 +57,7 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
onOk?.({
content: values.content,
keywords, // keywords
question_kwd: question,
available_int: checked ? 1 : 0, // available_int
});
} catch (errorInfo) {
Expand Down Expand Up @@ -91,6 +96,10 @@ const ChunkCreatingModal: React.FC<IModalProps<any> & kFProps> = ({
<p className="mb-2">{t('chunk.keyword')} *</p>
<EditTag tags={keywords} setTags={setKeywords} />
</section>
<section className="pt-2">
<p className="mb-2">{t('chunk.question')} *</p>
<EditTag tags={question} setTags={setQuestion} />
</section>
{chunkId && (
<section>
<Divider></Divider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,20 @@ export const useUpdateChunk = () => {
content,
keywords,
available_int,
question_kwd,
}: {
content: string;
keywords: string;
available_int: number;
question_kwd: string;
}) => {
const code = await createChunk({
content_with_weight: content,
doc_id: documentId,
chunk_id: chunkId,
important_kwd: keywords, // keywords
available_int,
question_kwd,
});

if (code === 0) {
Expand Down