feat: add knowledge management functionality with CRUD operations and database schema
- Implemented KnowledgeHandler for managing knowledge groups and items, including listing, creating, updating, and deleting operations. - Added database migration scripts to create necessary tables for knowledge management, including knowledge_groups, knowledge_items, knowledge_parse_tasks, and knowledge_chunks_meta. - Introduced prompt_rule_knowledge_groups table to associate prompt rules with knowledge groups.
This commit is contained in:
@@ -6,6 +6,7 @@ import type { PromptRule, PromptRuleGroup } from "@geo/shared-types";
|
||||
import { computed, reactive, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
import KnowledgeGroupSelect from "@/components/KnowledgeGroupSelect.vue";
|
||||
import { promptRulesApi } from "@/lib/api";
|
||||
import { formatError } from "@/lib/errors";
|
||||
|
||||
@@ -29,6 +30,7 @@ const form = reactive({
|
||||
default_tone: "",
|
||||
default_word_count: undefined as number | undefined,
|
||||
group_id: undefined as number | undefined,
|
||||
knowledge_group_ids: [] as number[],
|
||||
});
|
||||
|
||||
const groupsQuery = useQuery({
|
||||
@@ -50,6 +52,7 @@ watch(
|
||||
form.default_tone = rule?.default_tone ?? "";
|
||||
form.default_word_count = rule?.default_word_count ?? undefined;
|
||||
form.group_id = rule?.group_id ?? undefined;
|
||||
form.knowledge_group_ids = rule?.knowledge_group_ids ?? [];
|
||||
},
|
||||
);
|
||||
|
||||
@@ -62,6 +65,7 @@ const createMutation = useMutation({
|
||||
scene: form.scene.trim() || undefined,
|
||||
default_tone: form.default_tone.trim() || undefined,
|
||||
default_word_count: form.default_word_count,
|
||||
knowledge_group_ids: form.knowledge_group_ids,
|
||||
}),
|
||||
onSuccess: async (data) => {
|
||||
message.success(t("custom.messages.ruleCreated"));
|
||||
@@ -81,6 +85,7 @@ const updateMutation = useMutation({
|
||||
scene: form.scene.trim() || undefined,
|
||||
default_tone: form.default_tone.trim() || undefined,
|
||||
default_word_count: form.default_word_count,
|
||||
knowledge_group_ids: form.knowledge_group_ids,
|
||||
}),
|
||||
onSuccess: async () => {
|
||||
message.success(t("custom.messages.ruleUpdated"));
|
||||
@@ -197,6 +202,14 @@ async function handleSubmit(): Promise<void> {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="prompt-rule-drawer__field">
|
||||
<label class="prompt-rule-drawer__label">知识库引用:</label>
|
||||
<KnowledgeGroupSelect
|
||||
v-model="form.knowledge_group_ids"
|
||||
placeholder="可选,用于补充生成内容的背景信息"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
|
||||
Reference in New Issue
Block a user