feat(GraphRAG): enhance GraphRAG by graph community summary (#1801)

Co-authored-by: Florian <fanzhidongyzby@163.com>
Co-authored-by: KingSkyLi <15566300566@163.com>
Co-authored-by: aries_ckt <916701291@qq.com>
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: yvonneyx <zhuyuxin0627@gmail.com>
This commit is contained in:
M1n9X
2024-08-30 21:59:44 +08:00
committed by GitHub
parent 471689ba20
commit 759f7d99cc
59 changed files with 29316 additions and 411 deletions

View File

@@ -6,6 +6,7 @@ import os
from collections import defaultdict
from typing import Any, DefaultDict, Dict, List, Optional, Tuple, Type, cast
from dbgpt.app.component_configs import CFG
from dbgpt.core import Chunk, Embeddings
from dbgpt.core.awel.flow import (
FunctionDynamicOptions,
@@ -95,6 +96,7 @@ class VectorStoreConnector:
self._index_store_config = vector_store_config
self._register()
vector_store_type = self.__rewrite_index_store_type(vector_store_type)
if self._match(vector_store_type):
self.connector_class, self.config_class = connector[vector_store_type]
else:
@@ -124,6 +126,13 @@ class VectorStoreConnector:
logger.error("connect vector store failed: %s", e)
raise e
def __rewrite_index_store_type(self, index_store_type):
# Rewrite Knowledge Graph Type
if CFG.GRAPH_COMMUNITY_SUMMARY_ENABLED:
if index_store_type == "KnowledgeGraph":
return "CommunitySummaryKnowledgeGraph"
return index_store_type
@classmethod
def from_default(
cls,
@@ -270,6 +279,10 @@ class VectorStoreConnector:
"""
return self.client.delete_by_ids(ids=ids)
def truncate(self):
"""Truncate data."""
return self.client.truncate()
@property
def current_embeddings(self) -> Optional[Embeddings]:
"""Return the current embeddings."""