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

importing voyageai leads to "type error" #127

Open
rojas70 opened this issue Dec 28, 2024 · 1 comment
Open

importing voyageai leads to "type error" #127

rojas70 opened this issue Dec 28, 2024 · 1 comment

Comments

@rojas70
Copy link

rojas70 commented Dec 28, 2024

Greetings,

I am running anthropic-cookbook on Linux Ubuntu 20.04.
I am running the skills/classification guide:
https://github.com/anthropics/anthropic-cookbook/blob/main/skills/classification/guide.ipynb

I can run cells find until RAG augmentation, where I import voyageai:

import voyageai

I get the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[27], line 3
      1 import os
      2 import numpy as np
----> 3 import voyageai
      4 import pickle
      5 import json

File /media/juan/hdd/school/teaching/msai5533/02_lecs/code/anthropic-cookbook/.venv/lib/python3.8/site-packages/voyageai/__init__.py:24
     22 from voyageai.api_resources import Embedding, Reranking
     23 from voyageai.version import VERSION
---> 24 from voyageai.client import Client
     25 from voyageai.client_async import AsyncClient
     26 from voyageai.embeddings_utils import (
     27     get_embedding,
     28     get_embeddings,
     29     aget_embedding,
     30     aget_embeddings,
     31 )

File /media/juan/hdd/school/teaching/msai5533/02_lecs/code/anthropic-cookbook/.venv/lib/python3.8/site-packages/voyageai/client.py:12
      4 from tenacity import (
      5     Retrying,
      6     stop_after_attempt,
      7     wait_exponential_jitter,
      8     retry_if_exception_type,
      9 )
     11 import voyageai
---> 12 from voyageai._base import _BaseClient
     13 import voyageai.error as error
     14 from voyageai.util import default_api_key

File /media/juan/hdd/school/teaching/msai5533/02_lecs/code/anthropic-cookbook/.venv/lib/python3.8/site-packages/voyageai/_base.py:13
      9 from voyageai.util import default_api_key
     10 from voyageai.object import EmbeddingsObject, RerankingObject
---> 13 class _BaseClient:
     14     """Voyage AI Client
     15 
     16     Args:
   (...)
     19         timeout (float): Timeout in seconds.
     20     """
     22     def __init__(
     23         self,
     24         api_key: Optional[str] = None,
     25         max_retries: int = 0,
     26         timeout: Optional[float] = None,
     27     ) -> None:

File /media/juan/hdd/school/teaching/msai5533/02_lecs/code/anthropic-cookbook/.venv/lib/python3.8/site-packages/voyageai/_base.py:44, in _BaseClient()
     29     self.api_key = api_key or default_api_key()
     31     self._params = {
     32         "api_key": self.api_key,
     33         "request_timeout": timeout,
     34     }
     37 @abstractmethod    
     38 def embed(
     39     self,
     40     texts: List[str],
     41     model: Optional[str] = None,
     42     input_type: Optional[str] = None,
     43     truncation: bool = True,
---> 44 ) -> Union[EmbeddingsObject, Awaitable[EmbeddingsObject]]:
     45     pass
     47 @abstractmethod
     48 def rerank(
     49     self,
   (...)
     54     truncation: bool = True,
     55 ) -> Union[RerankingObject, Awaitable[RerankingObject]]:

TypeError: 'ABCMeta' object is not subscriptable

Note that I do have a voyageai key (though one should not be needed to import the module I believe). The key has been set in my .bashrc file via:
export VOYAGE_API_KEY='XXXXX'.

Please advice on how to proceed.

@rojas70
Copy link
Author

rojas70 commented Dec 28, 2024

This happened since I was using python3.8. It was solved with python3.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant