aurelio-labs/semantic-router

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

Closed this issue · 6 comments

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'

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

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.

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

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

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