1+ import logging
12import random
23from typing import List , Optional , Union
34
910from camel_database_agent .database .schema import QueryRecord
1011from camel_database_agent .knowledge .knowledge import DatabaseKnowledge
1112
13+ logger = logging .getLogger (__name__ )
14+
1215
1316class DatabaseKnowledgeQdrant (DatabaseKnowledge ):
1417 def __init__ (
@@ -18,24 +21,38 @@ def __init__(
1821 path : Optional [str ] = None ,
1922 ):
2023 self .path = path
21- super ().__init__ (
22- embedding = embedding ,
23- model = model ,
24- table_storage = QdrantStorage (
24+ try :
25+ table_storage = QdrantStorage (
2526 vector_dim = embedding .get_output_dim (),
2627 collection_name = "table_documents" ,
2728 path = path if path else ":memory:" ,
28- ),
29- data_storage = QdrantStorage (
29+ )
30+ data_storage = QdrantStorage (
3031 vector_dim = embedding .get_output_dim (),
3132 collection_name = "data_documents" ,
3233 path = path if path else ":memory:" ,
33- ),
34- query_storage = QdrantStorage (
34+ )
35+ query_storage = QdrantStorage (
3536 vector_dim = embedding .get_output_dim (),
3637 collection_name = "query_documents" ,
3738 path = path if path else ":memory:" ,
38- ),
39+ )
40+ except ValueError as e :
41+ logger .error (
42+ "Adjust your embedding model to output vectors with "
43+ "the same dimensions as the existing collection. "
44+ "Alternatively, delete the existing collection and "
45+ "recreate it with your current embedding dimensions "
46+ "(note: this will result in the loss of all existing "
47+ "data)."
48+ )
49+ raise e
50+ super ().__init__ (
51+ embedding = embedding ,
52+ model = model ,
53+ table_storage = table_storage ,
54+ data_storage = data_storage ,
55+ query_storage = query_storage ,
3956 )
4057
4158 def clear (self ) -> None :
0 commit comments