mirror of
https://github.com/SillyTavern/SillyTavern-Extras.git
synced 2026-01-26 17:20:04 +00:00
report number of items the embedding is being computed for
(since SentenceTransformer doesn't show that in the progress bar)
This commit is contained in:
@@ -601,7 +601,11 @@ def api_embeddings_compute():
|
||||
sentences: Union[str, List[str]] = data["text"]
|
||||
if not (isinstance(sentences, str) or (isinstance(sentences, list) and all(isinstance(x, str) for x in sentences))):
|
||||
abort(400, '"text" must be string or array of strings')
|
||||
print("Computing vector embedding")
|
||||
if isinstance(sentences, str):
|
||||
nitems = 1
|
||||
else:
|
||||
nitems = len(sentences)
|
||||
print(f"Computing vector embedding for {nitems} item{'s' if nitems != 1 else ''}")
|
||||
vectors: Union[np.array, List[np.array]] = sentence_embedder.encode(sentences,
|
||||
show_progress_bar=True, # on ST-extras console
|
||||
convert_to_numpy=True,
|
||||
|
||||
Reference in New Issue
Block a user