@@ -28,20 +28,20 @@ def __init__(self, config=None):
28
28
if config and "embedding_function" in config :
29
29
self .embedding_function = config .get ("embedding_function" )
30
30
else :
31
- from sentence_transformers import SentenceTransformer
32
- self .embedding_function = SentenceTransformer ( "sentence-transformers/ all-MiniLM-l6 -v2" )
31
+ from langchain_huggingface import HuggingFaceEmbeddings
32
+ self .embedding_function = HuggingFaceEmbeddings ( model_name = " all-MiniLM-L6 -v2" )
33
33
34
- self .sql_vectorstore = PGVector (
34
+ self .sql_collection = PGVector (
35
35
embeddings = self .embedding_function ,
36
36
collection_name = "sql" ,
37
37
connection = self .connection_string ,
38
38
)
39
- self .ddl_vectorstore = PGVector (
39
+ self .ddl_collection = PGVector (
40
40
embeddings = self .embedding_function ,
41
41
collection_name = "ddl" ,
42
42
connection = self .connection_string ,
43
43
)
44
- self .documentation_vectorstore = PGVector (
44
+ self .documentation_collection = PGVector (
45
45
embeddings = self .embedding_function ,
46
46
collection_name = "documentation" ,
47
47
connection = self .connection_string ,
@@ -94,16 +94,16 @@ def get_collection(self, collection_name):
94
94
case _:
95
95
raise ValueError ("Specified collection does not exist." )
96
96
97
- async def get_similar_question_sql (self , question : str ) -> list :
97
+ def get_similar_question_sql (self , question : str ) -> list :
98
98
documents = self .sql_collection .similarity_search (query = question , k = self .n_results )
99
99
return [ast .literal_eval (document .page_content ) for document in documents ]
100
100
101
- async def get_related_ddl (self , question : str , ** kwargs ) -> list :
102
- documents = await self .ddl_collection .similarity_search (query = question , k = self .n_results )
101
+ def get_related_ddl (self , question : str , ** kwargs ) -> list :
102
+ documents = self .ddl_collection .similarity_search (query = question , k = self .n_results )
103
103
return [document .page_content for document in documents ]
104
104
105
- async def get_related_documentation (self , question : str , ** kwargs ) -> list :
106
- documents = await self .documentation_collection .similarity_search (query = question , k = self .n_results )
105
+ def get_related_documentation (self , question : str , ** kwargs ) -> list :
106
+ documents = self .documentation_collection .similarity_search (query = question , k = self .n_results )
107
107
return [document .page_content for document in documents ]
108
108
109
109
def train (
@@ -251,15 +251,3 @@ def remove_collection(self, collection_name: str) -> bool:
251
251
252
252
def generate_embedding (self , * args , ** kwargs ):
253
253
pass
254
-
255
- def submit_prompt (self , * args , ** kwargs ):
256
- pass
257
-
258
- def system_message (self , message : str ) -> any :
259
- return {"role" : "system" , "content" : message }
260
-
261
- def user_message (self , message : str ) -> any :
262
- return {"role" : "user" , "content" : message }
263
-
264
- def assistant_message (self , message : str ) -> any :
265
- return {"role" : "assistant" , "content" : message }
0 commit comments