2323from veadk .database .relational .mysql_database import MysqlDatabase
2424from veadk .database .vector .opensearch_vector_database import OpenSearchVectorDatabase
2525from veadk .database .viking .viking_database import VikingDatabase
26- from veadk .database .viking .viking_memory_db import VikingDatabaseMemory
26+ from veadk .database .viking .viking_memory_db import VikingMemoryDatabase
2727from veadk .utils .logger import get_logger
2828
2929logger = get_logger (__name__ )
@@ -39,7 +39,7 @@ def add(self, data: list[str], index: str):
3939
4040 try :
4141 for _data in data :
42- self .client .add (key = index , data = _data )
42+ self .client .add (key = index , value = _data )
4343 logger .debug (f"Added { len (data )} texts to Redis database: index={ index } " )
4444 except Exception as e :
4545 logger .error (
@@ -84,7 +84,7 @@ def add(self, data: list[str], index: str):
8484 )
8585
8686 if not self .client .table_exists (index ):
87- logger .warning (f"Table { index } does not exist, creating.. ." )
87+ logger .warning (f"Table { index } does not exist, creating a new table ." )
8888 self .create_table (index )
8989
9090 for _data in data :
@@ -133,6 +133,7 @@ def add(self, data: list[str], index: str):
133133 self .client .add (data , collection_name = index )
134134
135135 def query (self , query : str , index : str , top_k : int ) -> list [str ]:
136+ # FIXME: confirm
136137 self ._validate_index (index )
137138
138139 logger .debug (
@@ -159,6 +160,7 @@ def get_or_create_collection(self, collection_name: str):
159160 if not self .client .collection_exists (collection_name ):
160161 self .client .create_collection (collection_name )
161162
163+ # FIXME
162164 count = 0
163165 while not self .client .collection_exists (collection_name ):
164166 time .sleep (1 )
@@ -174,6 +176,7 @@ def add(
174176 self ._validate_index (index )
175177
176178 logger .debug (f"Adding documents to Viking database: collection_name={ index } " )
179+
177180 self .get_or_create_collection (index )
178181 self .client .add (data , collection_name = index , ** kwargs )
179182
@@ -189,22 +192,23 @@ def query(self, query: str, index: str, top_k: int) -> list[str]:
189192 return self .client .query (query , collection_name = index , top_k = top_k )
190193
191194
192- class VikingDatabaseMemoryAdapter (BaseModel ):
195+ class VikingMemoryDatabaseAdapter (BaseModel ):
193196 model_config = ConfigDict (arbitrary_types_allowed = True )
194197
195- client : VikingDatabaseMemory
198+ client : VikingMemoryDatabase
196199
197200 def _validate_index (self , index : str ):
198201 # TODO
199202 pass
200203
201- def add (self , data : list [str ], index : str ):
204+ def add (self , data : list [str ], index : str , ** kwargs ):
202205 self ._validate_index (index )
203206
204207 logger .debug (
205208 f"Adding documents to Viking database memory: collection_name={ index } data_len={ len (data )} "
206209 )
207210
211+ # TODO: parse user_id
208212 self .client .add (data , collection_name = index )
209213
210214 def query (self , query : str , index : str , top_k : int ):
@@ -236,7 +240,7 @@ def query(self, query: str, **kwargs):
236240 LocalDataBase : LocalDatabaseAdapter ,
237241 VikingDatabase : VikingDatabaseAdapter ,
238242 OpenSearchVectorDatabase : VectorDatabaseAdapter ,
239- VikingDatabaseMemory : VikingDatabaseMemoryAdapter ,
243+ VikingMemoryDatabase : VikingMemoryDatabaseAdapter ,
240244}
241245
242246
0 commit comments