MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / save

Method save

apps/knowledge/vector/base_vector.py:88–124  ·  view source on GitHub ↗

插入向量数据 :param source_id: 资源id :param knowledge_id: 知识库id :param text: 文本 :param source_type: 资源类型 :param document_id: 文档id :param is_active: 是否禁用 :param embedding: 向量化处理器 :param paragraph_id 段落id :return: bool

(
        self,
        text,
        source_type: SourceType,
        knowledge_id: str,
        document_id: str,
        paragraph_id: str,
        source_id: str,
        is_active: bool,
        embedding: Embeddings,
    )

Source from the content-addressed store, hash-verified

86 return True
87
88 def save(
89 self,
90 text,
91 source_type: SourceType,
92 knowledge_id: str,
93 document_id: str,
94 paragraph_id: str,
95 source_id: str,
96 is_active: bool,
97 embedding: Embeddings,
98 ):
99 """
100 插入向量数据
101 :param source_id: 资源id
102 :param knowledge_id: 知识库id
103 :param text: 文本
104 :param source_type: 资源类型
105 :param document_id: 文档id
106 :param is_active: 是否禁用
107 :param embedding: 向量化处理器
108 :param paragraph_id 段落id
109 :return: bool
110 """
111 self.save_pre_handler()
112 data = {
113 "document_id": document_id,
114 "paragraph_id": paragraph_id,
115 "knowledge_id": knowledge_id,
116 "is_active": is_active,
117 "source_id": source_id,
118 "source_type": source_type,
119 "text": text,
120 }
121 chunk_list = chunk_data(data)
122 result = sub_array(chunk_list)
123 for child_array in result:
124 self._batch_save(child_array, embedding, lambda: False)
125
126 def batch_save(self, data_list: List[Dict], embedding: Embeddings, is_the_task_interrupted):
127 """

Callers 4

_saveMethod · 0.45
postMethod · 0.45
postMethod · 0.45
postMethod · 0.45

Calls 4

save_pre_handlerMethod · 0.95
_batch_saveMethod · 0.95
sub_arrayFunction · 0.90
chunk_dataFunction · 0.85

Tested by

no test coverage detected