Skip to content

Commit

Permalink
fix: move embeds type to dunder
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescalam committed Oct 10, 2024
1 parent e9cd3ab commit 56a7e17
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions semantic_router/encoders/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class CohereEncoder(BaseEncoder):
_client: Any = PrivateAttr()
_embed_type: Any = PrivateAttr()
type: str = "cohere"
input_type: Optional[str] = "search_query"

Expand Down Expand Up @@ -40,7 +41,7 @@ def _initialize_client(self, cohere_api_key: Optional[str] = None):
try:
import cohere
from cohere.types.embed_response import EmbeddingsByTypeEmbedResponse
self.EmbeddingsByTypeEmbedResponse = EmbeddingsByTypeEmbedResponse
self._embed_type = EmbeddingsByTypeEmbedResponse
except ImportError:
raise ImportError(
"Please install Cohere to use CohereEncoder. "
Expand All @@ -66,7 +67,7 @@ def __call__(self, docs: List[str]) -> List[List[float]]:
texts=docs, input_type=self.input_type, model=self.name
)
# Check for unsupported type.
if isinstance(embeds, self.EmbeddingsByTypeEmbedResponse):
if isinstance(embeds, self._embed_type):
raise NotImplementedError(
"Handling of EmbedByTypeResponseEmbeddings is not implemented."
)
Expand Down

0 comments on commit 56a7e17

Please sign in to comment.