mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-14 05:31:40 +00:00
chore: Fix package name conflict error (#1099)
This commit is contained in:
44
dbgpt/rag/operators/schema_linking.py
Normal file
44
dbgpt/rag/operators/schema_linking.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from dbgpt.core import LLMClient
|
||||
from dbgpt.core.awel import MapOperator
|
||||
from dbgpt.datasource.rdbms.base import RDBMSDatabase
|
||||
from dbgpt.rag.schemalinker.schema_linking import SchemaLinking
|
||||
from dbgpt.storage.vector_store.connector import VectorStoreConnector
|
||||
|
||||
|
||||
class SchemaLinkingOperator(MapOperator[Any, Any]):
|
||||
"""The Schema Linking Operator."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
top_k: int = 5,
|
||||
connection: Optional[RDBMSDatabase] = None,
|
||||
llm: Optional[LLMClient] = None,
|
||||
model_name: Optional[str] = None,
|
||||
vector_store_connector: Optional[VectorStoreConnector] = None,
|
||||
**kwargs
|
||||
):
|
||||
"""Init the schema linking operator
|
||||
Args:
|
||||
connection (RDBMSDatabase): The connection.
|
||||
llm (Optional[LLMClient]): base llm
|
||||
"""
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self._schema_linking = SchemaLinking(
|
||||
top_k=top_k,
|
||||
connection=connection,
|
||||
llm=llm,
|
||||
model_name=model_name,
|
||||
vector_store_connector=vector_store_connector,
|
||||
)
|
||||
|
||||
async def map(self, query: str) -> str:
|
||||
"""retrieve table schemas.
|
||||
Args:
|
||||
query (str): query.
|
||||
Return:
|
||||
str: schema info
|
||||
"""
|
||||
return str(await self._schema_linking.schema_linking_with_llm(query))
|
Reference in New Issue
Block a user