Skip to content

Commit 35fe162

Browse files
committed
feat: Knowledge write node chunk embeding
1 parent 8a1284d commit 35fe162

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-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
@@ -8781,4 +8781,7 @@ msgid "SAML2 Log in"
87818781
msgstr ""
87828782

87838783
msgid "SAML2 SSO"
8784+
msgstr ""
8785+
8786+
msgid "Workflow"
87848787
msgstr ""

apps/locales/zh_CN/LC_MESSAGES/django.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8908,3 +8908,6 @@ msgstr "SAML2 登录"
89088908

89098909
msgid "SAML2 SSO"
89108910
msgstr "SAML2 单点登录"
8911+
8912+
msgid "Workflow"
8913+
msgstr "工作流"

apps/locales/zh_Hant/LC_MESSAGES/django.po

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8907,4 +8907,7 @@ msgid "SAML2 Log in"
89078907
msgstr "SAML2 登入"
89088908

89098909
msgid "SAML2 SSO"
8910-
msgstr "SAML2 單點登入"
8910+
msgstr "SAML2 單點登入"
8911+
8912+
msgid "Workflow"
8913+
msgstr "工作流"

0 commit comments

Comments
 (0)