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

ImportError due to class name typo in encoders/cohere.py (easy fix) #422

Closed
kwschultz opened this issue Sep 20, 2024 · 6 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@kwschultz
Copy link

There is a typo in a class name that causes an ImportError on running import semantic_router.
Can be fixed by replacing EmbedResponse_EmbeddingsByType with the correct name EmbeddingsByTypeEmbedResponse in the file semantic_router/encoders/cohere.py.

Envs with error reproduced:

  • Google Colab, python 3.10, semantic_router==0.0.65
  • Mac M1, anaconda Python 3.11, semantic_router==0.0.65

To generate the error

pip install semantic-router
python

>>> import semantic_router
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/anaconda3/lib/python3.11/site-packages/semantic_router/__init__.py", line 1, in <module>
    from semantic_router.hybrid_layer import HybridRouteLayer
  File "/opt/anaconda3/lib/python3.11/site-packages/semantic_router/hybrid_layer.py", line 6, in <module>
    from semantic_router.encoders import (
  File "/opt/anaconda3/lib/python3.11/site-packages/semantic_router/encoders/__init__.py", line 7, in <module>
    from semantic_router.encoders.cohere import CohereEncoder
  File "/opt/anaconda3/lib/python3.11/site-packages/semantic_router/encoders/cohere.py", line 5, in <module>
    from cohere.types.embed_response import EmbedResponse_EmbeddingsByType
ImportError: cannot import name 'EmbedResponse_EmbeddingsByType' from 'cohere.types.embed_response' (/opt/anaconda3/lib/python3.11/site-packages/cohere/types/embed_response.py)

To fix the error

sed -i -e 's/EmbedResponse_EmbeddingsByType/EmbeddingsByTypeEmbedResponse/g' 'path/to/install/semantic_router/encoders/cohere.py'
@mahdi-b
Copy link

mahdi-b commented Sep 20, 2024

Seems to be an issue with the new Cohere 5.9.4. It works for me with cohere==5.9.2.

@robhaslinger
Copy link

I had a similar issue see #425

Can confirm that downgrading to cohere==5.9.2 does seem to solve the problem .. but I imagine neither this or the 'sed' solution described above is a permanent fix.

@jamescalam
Copy link
Member

we are reviewing a fix raised in #430 and will have this resolved asap

@jamescalam jamescalam added the bug Something isn't working label Sep 23, 2024
@jamescalam
Copy link
Member

Fixed in #430 #431 and new release created with the changes (0.0.67) https://github.com/aurelio-labs/semantic-router/releases/tag/v0.0.67

@jamescalam
Copy link
Member

we noticed a bug, yanking release 0.0.67 and releasing 0.0.68 #433 - will be merged and released soon

@jamescalam
Copy link
Member

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

5 participants