Skip to content

Commit

Permalink
fix(rag): Fix schema linking error (#1637)
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc authored Jun 15, 2024
1 parent bb7f41b commit e1e94f9
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions dbgpt/rag/schemalinker/schema_linking.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
ModelRequest,
)
from dbgpt.datasource.base import BaseConnector
from dbgpt.rag.index.base import IndexStoreBase
from dbgpt.rag.schemalinker.base_linker import BaseSchemaLinker
from dbgpt.rag.summary.rdbms_db_summary import _parse_db_summary
from dbgpt.serve.rag.connector import VectorStoreConnector
from dbgpt.util.chat_util import run_async_tasks

INSTRUCTION = """
Expand Down Expand Up @@ -46,21 +46,19 @@ def __init__(
model_name: str,
llm: LLMClient,
top_k: int = 5,
vector_store_connector: Optional[VectorStoreConnector] = None,
**kwargs
index_store: Optional[IndexStoreBase] = None,
):
"""Create the schema linking instance.
Args:
connection (Optional[BaseConnector]): BaseConnector connection.
llm (Optional[LLMClient]): base llm
"""
super().__init__(**kwargs)
self._top_k = top_k
self._connector = connector
self._llm = llm
self._model_name = model_name
self._vector_store_connector = vector_store_connector
self._index_store = index_store

def _schema_linking(self, query: str) -> List:
"""Get all db schema info."""
Expand All @@ -71,11 +69,10 @@ def _schema_linking(self, query: str) -> List:

def _schema_linking_with_vector_db(self, query: str) -> List[Chunk]:
queries = [query]
if not self._vector_store_connector:
if not self._index_store:
raise ValueError("Vector store connector is not provided.")
candidates = [
self._vector_store_connector.similar_search(query, self._top_k)
for query in queries
self._index_store.similar_search(query, self._top_k) for query in queries
]
return cast(List[Chunk], reduce(lambda x, y: x + y, candidates))

Expand Down

0 comments on commit e1e94f9

Please sign in to comment.