feat(lightrag): Implement mix search mode combining knowledge graph and vector retrieval
- Add 'mix' mode to QueryParam for hybrid search functionality - Implement mix_kg_vector_query to combine knowledge graph and vector search results - Update LightRAG class to handle 'mix' mode queries - Enhance README with examples and explanations for the new mix search mode - Introduce new prompt structure for generating responses based on combined search results
This commit is contained in:
@@ -16,6 +16,7 @@ from .operate import (
|
||||
# local_query,global_query,hybrid_query,
|
||||
kg_query,
|
||||
naive_query,
|
||||
mix_kg_vector_query,
|
||||
)
|
||||
|
||||
from .utils import (
|
||||
@@ -630,6 +631,25 @@ class LightRAG:
|
||||
embedding_func=None,
|
||||
),
|
||||
)
|
||||
elif param.mode == "mix":
|
||||
response = await mix_kg_vector_query(
|
||||
query,
|
||||
self.chunk_entity_relation_graph,
|
||||
self.entities_vdb,
|
||||
self.relationships_vdb,
|
||||
self.chunks_vdb,
|
||||
self.text_chunks,
|
||||
param,
|
||||
asdict(self),
|
||||
hashing_kv=self.llm_response_cache
|
||||
if self.llm_response_cache
|
||||
and hasattr(self.llm_response_cache, "global_config")
|
||||
else self.key_string_value_json_storage_cls(
|
||||
namespace="llm_response_cache",
|
||||
global_config=asdict(self),
|
||||
embedding_func=None,
|
||||
),
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Unknown mode {param.mode}")
|
||||
await self._query_done()
|
||||
|
Reference in New Issue
Block a user