add tqdm to embeddings (#7205)

for longer running embeddings, can be helpful to visualize
pull/7212/head
Harrison Chase 1 year ago committed by GitHub
parent 6fc24743b7
commit 7b585c7585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -298,7 +298,13 @@ class OpenAIEmbeddings(BaseModel, Embeddings):
batched_embeddings = []
_chunk_size = chunk_size or self.chunk_size
for i in range(0, len(tokens), _chunk_size):
try:
import tqdm
_iter = tqdm.tqdm(range(0, len(tokens), _chunk_size))
except ImportError:
_iter = range(0, len(tokens), _chunk_size)
for i in _iter:
response = embed_with_retry(
self,
input=tokens[i : i + _chunk_size],

Loading…
Cancel
Save