@@ -98,26 +98,54 @@ def convert_gapic_to_embedding_model_config(
98
98
return embedding_model_config
99
99
100
100
101
+ def _check_weaviate (gapic_vector_db : RagVectorDbConfig ) -> bool :
102
+ try :
103
+ return gapic_vector_db .__contains__ ("weaviate" )
104
+ except AttributeError :
105
+ return gapic_vector_db .weaviate .ByteSize () > 0
106
+
107
+
108
+ def _check_vertex_feature_store (gapic_vector_db : RagVectorDbConfig ) -> bool :
109
+ try :
110
+ return gapic_vector_db .__contains__ ("vertex_feature_store" )
111
+ except AttributeError :
112
+ return gapic_vector_db .vertex_feature_store .ByteSize () > 0
113
+
114
+
115
+ def _check_pinecone (gapic_vector_db : RagVectorDbConfig ) -> bool :
116
+ try :
117
+ return gapic_vector_db .__contains__ ("pinecone" )
118
+ except AttributeError :
119
+ return gapic_vector_db .pinecone .ByteSize () > 0
120
+
121
+
122
+ def _check_vertex_vector_search (gapic_vector_db : RagVectorDbConfig ) -> bool :
123
+ try :
124
+ return gapic_vector_db .__contains__ ("vertex_vector_search" )
125
+ except AttributeError :
126
+ return gapic_vector_db .vertex_vector_search .ByteSize () > 0
127
+
128
+
101
129
def convert_gapic_to_vector_db (
102
130
gapic_vector_db : RagVectorDbConfig ,
103
131
) -> Union [Weaviate , VertexFeatureStore , VertexVectorSearch , Pinecone ]:
104
132
"""Convert Gapic RagVectorDbConfig to Weaviate, VertexFeatureStore, VertexVectorSearch, or Pinecone."""
105
- if gapic_vector_db . __contains__ ( "weaviate" ):
133
+ if _check_weaviate ( gapic_vector_db ):
106
134
return Weaviate (
107
135
weaviate_http_endpoint = gapic_vector_db .weaviate .http_endpoint ,
108
136
collection_name = gapic_vector_db .weaviate .collection_name ,
109
137
api_key = gapic_vector_db .api_auth .api_key_config .api_key_secret_version ,
110
138
)
111
- elif gapic_vector_db . __contains__ ( "vertex_feature_store" ):
139
+ elif _check_vertex_feature_store ( gapic_vector_db ):
112
140
return VertexFeatureStore (
113
141
resource_name = gapic_vector_db .vertex_feature_store .feature_view_resource_name ,
114
142
)
115
- elif gapic_vector_db . __contains__ ( "pinecone" ):
143
+ elif _check_pinecone ( gapic_vector_db ):
116
144
return Pinecone (
117
145
index_name = gapic_vector_db .pinecone .index_name ,
118
146
api_key = gapic_vector_db .api_auth .api_key_config .api_key_secret_version ,
119
147
)
120
- elif gapic_vector_db . __contains__ ( "vertex_vector_search" ):
148
+ elif _check_vertex_vector_search ( gapic_vector_db ):
121
149
return VertexVectorSearch (
122
150
index_endpoint = gapic_vector_db .vertex_vector_search .index_endpoint ,
123
151
index = gapic_vector_db .vertex_vector_search .index ,
0 commit comments