Skip to content

Commit a22f6f3

Browse files
committed
feat: Knowledge write node chunk embeding
1 parent bfae088 commit a22f6f3

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

apps/application/flow/step_node/knowledge_write_node/impl/base_knowledge_write_node.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from common.utils.common import bulk_create_in_batches
2121
from knowledge.models import Document, KnowledgeType, Paragraph, File, FileSourceType, Problem, ProblemParagraphMapping
2222
from knowledge.serializers.common import ProblemParagraphObject, ProblemParagraphManage
23+
from knowledge.serializers.document import DocumentSerializers
2324

2425

2526
class ParagraphInstanceSerializer(serializers.Serializer):
@@ -187,9 +188,19 @@ def save(self, document_list):
187188

188189
return document_model_list, knowledge_id, workspace_id
189190

191+
@staticmethod
192+
def post_embedding(document_model_list, knowledge_id, workspace_id):
193+
for document in document_model_list:
194+
DocumentSerializers.Operate(data={
195+
'knowledge_id': knowledge_id,
196+
'document_id': document.id,
197+
'workspace_id': workspace_id
198+
}).refresh()
199+
190200
def execute(self, documents, **kwargs) -> NodeResult:
191201

192202
document_model_list, knowledge_id, workspace_id = self.save(documents)
203+
self.post_embedding(document_model_list, knowledge_id, workspace_id)
193204

194205
write_content_list = [{
195206
"name": document.get("name"),

apps/common/sql/list_embedding_text.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ SELECT
55
problem.knowledge_id AS knowledge_id,
66
0 AS source_type,
77
problem."content" AS "text",
8-
paragraph.is_active AS is_active
8+
paragraph.is_active AS is_active,
9+
paragraph.chunks AS chunks
910
FROM
1011
problem problem
1112
LEFT JOIN problem_paragraph_mapping problem_paragraph_mapping ON problem_paragraph_mapping.problem_id=problem."id"
@@ -20,7 +21,8 @@ SELECT
2021
paragraph.knowledge_id AS knowledge_id,
2122
1 AS source_type,
2223
concat_ws(E'\n',paragraph.title,paragraph."content") AS "text",
23-
paragraph.is_active AS is_active
24+
paragraph.is_active AS is_active,
25+
paragraph.chunks AS chunks
2426
FROM
2527
paragraph paragraph
2628

apps/locales/en_US/LC_MESSAGES/django.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8772,4 +8772,7 @@ msgid "Application token usage statistics"
87728772
msgstr ""
87738773

87748774
msgid "Application top question statistics"
8775+
msgstr ""
8776+
8777+
msgid "Workflow"
87758778
msgstr ""

apps/locales/zh_CN/LC_MESSAGES/django.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8899,3 +8899,6 @@ msgstr "应用令牌使用统计"
88998899

89008900
msgid "Application top question statistics"
89018901
msgstr "应用提问次数统计"
8902+
8903+
msgid "Workflow"
8904+
msgstr "工作流"

apps/locales/zh_Hant/LC_MESSAGES/django.po

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8898,4 +8898,7 @@ msgid "Application token usage statistics"
88988898
msgstr "應用令牌使用統計"
88998899

89008900
msgid "Application top question statistics"
8901-
msgstr "應用提問次數統計"
8901+
msgstr "應用提問次數統計"
8902+
8903+
msgid "Workflow"
8904+
msgstr "工作流"

ui/src/views/knowledge/KnowledgeSetting.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,26 @@
7474
</div>
7575
</div>
7676
</el-card>
77+
<el-card
78+
shadow="never"
79+
class="mb-8 w-full layout-bg"
80+
style="line-height: 22px"
81+
v-if="detail?.type === 4"
82+
>
83+
<div class="flex align-center">
84+
<el-avatar shape="square" :size="32" style="background: #753DEF">
85+
<img src="@/assets/knowledge/logo_workflow.svg" style="width: 100%" alt=""/>
86+
</el-avatar>
87+
<div>
88+
<p>
89+
<el-text>{{ $t('views.knowledge.knowledgeType.workflowKnowledge') }}</el-text>
90+
</p>
91+
<el-text type="info"
92+
>{{ $t('views.knowledge.knowledgeType.workflowKnowledge') }}
93+
</el-text>
94+
</div>
95+
</div>
96+
</el-card>
7797
</el-form-item>
7898
<el-form-item
7999
:label="$t('views.knowledge.form.source_url.label')"

0 commit comments

Comments
 (0)