38
38
)
39
39
from vertexai .preview .rag .utils .resources import (
40
40
EmbeddingModelConfig ,
41
+ Pinecone ,
41
42
RagCorpus ,
42
43
RagFile ,
43
44
SlackChannelsSource ,
@@ -98,8 +99,8 @@ def convert_gapic_to_embedding_model_config(
98
99
99
100
def convert_gapic_to_vector_db (
100
101
gapic_vector_db : RagVectorDbConfig ,
101
- ) -> Union [Weaviate , VertexFeatureStore ]:
102
- """Convert Gapic RagVectorDbConfig to Weaviate or VertexFeatureStore ."""
102
+ ) -> Union [Weaviate , VertexFeatureStore , Pinecone ]:
103
+ """Convert Gapic RagVectorDbConfig to Weaviate, VertexFeatureStore, or Pinecone ."""
103
104
if gapic_vector_db .__contains__ ("weaviate" ):
104
105
return Weaviate (
105
106
weaviate_http_endpoint = gapic_vector_db .weaviate .http_endpoint ,
@@ -110,6 +111,11 @@ def convert_gapic_to_vector_db(
110
111
return VertexFeatureStore (
111
112
resource_name = gapic_vector_db .vertex_feature_store .feature_view_resource_name ,
112
113
)
114
+ elif gapic_vector_db .__contains__ ("pinecone" ):
115
+ return Pinecone (
116
+ index_name = gapic_vector_db .pinecone .index_name ,
117
+ api_key = gapic_vector_db .api_auth .api_key_config .api_key_secret_version ,
118
+ )
113
119
else :
114
120
return None
115
121
@@ -395,7 +401,7 @@ def set_embedding_model_config(
395
401
396
402
397
403
def set_vector_db (
398
- vector_db : Union [Weaviate , VertexFeatureStore ],
404
+ vector_db : Union [Weaviate , VertexFeatureStore , Pinecone ],
399
405
rag_corpus : GapicRagCorpus ,
400
406
) -> None :
401
407
"""Sets the vector db configuration for the rag corpus."""
@@ -423,5 +429,21 @@ def set_vector_db(
423
429
feature_view_resource_name = resource_name ,
424
430
),
425
431
)
432
+ elif isinstance (vector_db , Pinecone ):
433
+ index_name = vector_db .index_name
434
+ api_key = vector_db .api_key
435
+
436
+ rag_corpus .rag_vector_db_config = RagVectorDbConfig (
437
+ pinecone = RagVectorDbConfig .Pinecone (
438
+ index_name = index_name ,
439
+ ),
440
+ api_auth = api_auth .ApiAuth (
441
+ api_key_config = api_auth .ApiAuth .ApiKeyConfig (
442
+ api_key_secret_version = api_key
443
+ ),
444
+ ),
445
+ )
426
446
else :
427
- raise TypeError ("vector_db must be a Weaviate or VertexFeatureStore." )
447
+ raise TypeError (
448
+ "vector_db must be a Weaviate, VertexFeatureStore, or Pinecone."
449
+ )
0 commit comments