Skip to content
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

Update examples/utils/embeddings_utils.py to API V1 #855

Closed
gaborcselle opened this issue Nov 13, 2023 · 8 comments
Closed

Update examples/utils/embeddings_utils.py to API V1 #855

gaborcselle opened this issue Nov 13, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@gaborcselle
Copy link
Contributor

gaborcselle commented Nov 13, 2023

The file examples/utils/embeddings_utils.py needs to be updated to API V1. A number of related .ipynb notebooks are failing with depracation errors.

FIX: I have drafted a PR: embeddings_utils_v1_fixes.diff to fix this issue.

Identify the file to be fixed

Describe the problem
The embeddings_utils.py file has not been updated to API V1 which causes a number of errors:

  1. Uses a* methods such as acreate
  2. Doesn't use new names, e.g. openai.Embedding.create() -> client.embeddings.create()
  3. Uses engine keyword in function calls when it should use model

This causes a number of the example .ipynb notebooks to fail as well.

Describe a solution

  1. Update embeddings_utils.py to API V1 per the migration guide.
  2. Update related Python notebooks in the /examples/ directory.3.

Additional context
I'd like push this diff as a PR: embeddings_utils_v1_fixes.diff.

This diff includes updates for embeddings_utils.py and related .ipynb notebooks. I have manually tested all related .ipynb notebooks that import embeddings_utils.py and confirm that they work with API version 1.2.3.

@gaborcselle gaborcselle added the bug Something isn't working label Nov 13, 2023
@simonpfish
Copy link
Collaborator

Hi @gaborcselle! Thank you for flagging and fixing. You can open a PR by forking the repository.

@jhills20 for visibility

@gaborcselle
Copy link
Contributor Author

Great, working on that. PR coming shortly.

@gaborcselle
Copy link
Contributor Author

PR is up, thanks @simonpfish and @jhills20!

@gaborcselle gaborcselle changed the title Update examples/utils/embeddings_utils.py to API V1 (includes fix) Update examples/utils/embeddings_utils.py to API V1 Nov 14, 2023
@beshr-sab23
Copy link

Hi!
I am getting an error when try to use utils.embeddings_utils
from utils.embeddings_utils import get_embedding
error: ModuleNotFoundError: No module named 'utils.embeddings_utils'

In Colab, I've ran !pip install --upgrade openai and !pip install utils

Does anyone know how to solve this error. Thanks

@danthedanman
Copy link

Hi! I am getting an error when try to use utils.embeddings_utils from utils.embeddings_utils import get_embedding error: ModuleNotFoundError: No module named 'utils.embeddings_utils'

In Colab, I've ran !pip install --upgrade openai and !pip install utils

Does anyone know how to solve this error. Thanks

I am seeing the same error.

@beshr-sab23
Copy link

Hi! I am getting an error when try to use utils.embeddings_utils from utils.embeddings_utils import get_embedding error: ModuleNotFoundError: No module named 'utils.embeddings_utils'
In Colab, I've ran !pip install --upgrade openai and !pip install utils
Does anyone know how to solve this error. Thanks

I am seeing the same error.

Use this instead:
def get_embedding(text, model="text-embedding-ada-002"):
text = text.replace("\n", " ")
return client.embeddings.create(input = [text], model=model).data[0].embedding

resouces: https://platform.openai.com/docs/guides/embeddings/use-cases

@gaborcselle
Copy link
Contributor Author

Thanks @beshr-sab23 and @danthedanman for flagging, I'll take a look at this tomorrow.

@gaborcselle
Copy link
Contributor Author

@beshr-sab23 what directory is the file in that you are calling from utils.embeddings_utils import get_embedding from? that import statement will only work for .ipynb and .py files located in the /examples directory of the repo.

I just re-tested the import statement locally, with a current version of the repo's main branch, and works fine.

Thanks and let me know! Gabor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants