Skip to content

Embedding.create() fails when it receives a list of strings that contains an empty string #588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions openai/embeddings_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def get_embeddings(
) -> List[List[float]]:
assert len(list_of_text) <= 2048, "The batch size should not be larger than 2048."

for i in list_of_text:
if i == " ":
# replce the space in the middle of the string
list_of_text[i] = i.replace(" ", '')
else: continue

# replace newlines, which can negatively affect performance.
list_of_text = [text.replace("\n", " ") for text in list_of_text]

Expand Down