@@ -43,6 +43,7 @@ def __init__(
4343 dimension : int = 768 ,
4444 spec : dict [str , Any ] | None = None ,
4545 metric : Literal ["cosine" , "euclidean" , "dotproduct" ] = "cosine" ,
46+ show_progress : bool = True ,
4647 ):
4748 """
4849 Creates a new PineconeDocumentStore instance.
@@ -62,6 +63,8 @@ def __init__(
6263 If not provided, a default spec with serverless deployment in the `us-east-1` region will be used
6364 (compatible with the free tier).
6465 :param metric: The metric to use for similarity search. This parameter is only used when creating a new index.
66+ :param show_progress: Whether to show a progress bar when upserting documents. Set to False to disable
67+ (e.g. in tests or scripts where quiet output is preferred).
6568
6669 """
6770 self .api_key = api_key
@@ -72,6 +75,7 @@ def __init__(
7275 self .spec = spec
7376 self .dimension = dimension
7477 self .index_name = index
78+ self .show_progress = show_progress
7579
7680 self ._index : _Index | None = None
7781 self ._async_index : _IndexAsyncio | None = None
@@ -199,6 +203,7 @@ def to_dict(self) -> dict[str, Any]:
199203 namespace = self .namespace ,
200204 batch_size = self .batch_size ,
201205 metric = self .metric ,
206+ show_progress = self .show_progress ,
202207 )
203208
204209 def count_documents (self ) -> int :
@@ -244,7 +249,10 @@ def write_documents(self, documents: list[Document], policy: DuplicatePolicy = D
244249 documents_for_pinecone = self ._prepare_documents_for_writing (documents , policy )
245250
246251 result = self ._index .upsert (
247- vectors = documents_for_pinecone , namespace = self .namespace , batch_size = self .batch_size
252+ vectors = documents_for_pinecone ,
253+ namespace = self .namespace ,
254+ batch_size = self .batch_size ,
255+ show_progress = self .show_progress ,
248256 )
249257
250258 # if the operation is successful, result will have the upserted_count attribute
@@ -268,7 +276,10 @@ async def write_documents_async(
268276 documents_for_pinecone = self ._prepare_documents_for_writing (documents , policy )
269277
270278 result = await self ._async_index .upsert (
271- vectors = documents_for_pinecone , namespace = self .namespace , batch_size = self .batch_size
279+ vectors = documents_for_pinecone ,
280+ namespace = self .namespace ,
281+ batch_size = self .batch_size ,
282+ show_progress = self .show_progress ,
272283 )
273284
274285 # if the operation is successful, result will have the upserted_count attribute
0 commit comments