voyage-ai / voyageai-python

Voyage AI Official Python Library
https://www.voyageai.com
MIT License
37 stars 5 forks source link

AttributeError: 'RecentlyUsedContainer' object has no attribute 'ContainerCls when #3

Open GildeshAbhay opened 5 months ago

GildeshAbhay commented 5 months ago

I have this code here

  content = document["content"]
  doc = Document(text=content)
  node_parser = HierarchicalNodeParser.from_defaults(chunk_sizes=chunk_size)
  nodes = node_parser.get_nodes_from_documents([doc])
  storage_context = StorageContext.from_defaults()
  storage_context.docstore.add_documents(nodes)
  index = VectorStoreIndex(nodes, storage_context=storage_context , embed_model=embed_model)

this is the error drilldown

`index = VectorStoreIndex(nodes, storage_context=storage_context , embed_model=embed_model) Traceback (most recent call last):

File "C:\Users\abhay.saini\AppData\Local\Temp\ipykernel_18680\1374210055.py", line 1, in <cell line: 1> index = VectorStoreIndex(nodes, storage_context=storage_context , embed_model=embed_model)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 75, in init super().init(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\base.py", line 94, in init index_struct = self.build_index_from_nodes(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 308, in build_index_from_nodes return self._build_index_from_nodes(nodes, **insert_kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 280, in _build_index_from_nodes self._add_nodes_to_index(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 233, in _add_nodes_to_index nodes_batch = self._get_node_with_embedding(nodes_batch, show_progress)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 141, in _get_node_with_embedding id_to_embed_map = embed_nodes(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\utils.py", line 138, in embed_nodes new_embeddings = embed_model.get_text_embedding_batch(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\dispatcher.py", line 102, in wrapper self.span_drop(*args, id=id, err=e, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\dispatcher.py", line 77, in span_drop h.span_drop(*args, id=id, err=err, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\span_handlers\base.py", line 48, in span_drop span = self.prepare_to_drop_span(*args, id=id, err=err, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\span_handlers\null.py", line 35, in prepare_to_drop_span raise err

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\dispatcher.py", line 100, in wrapper result = func(*args, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\base\embeddings\base.py", line 280, in get_text_embedding_batch embeddings = self._get_text_embeddings(cur_batch)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\embeddings\voyageai\base.py", line 103, in _get_text_embeddings return self._get_embedding(texts, input_type="document")

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\embeddings\voyageai\base.py", line 65, in _get_embedding return self._client.embed(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\client.py", line 36, in embed response = voyageai.Embedding.create(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\api_resources\embedding.py", line 29, in create response = super().create(*args, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\api_resources\abstract\engine_apiresource.py", line 115, in create response, , api_key = requestor.request(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\api_resources\api_requestor.py", line 289, in request result = self.request_raw(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\api_resources\api_requestor.py", line 533, in request_raw _thread_context.session = _make_session()

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\api_resources\api_requestor.py", line 88, in _make_session s = requests.Session()

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 450, in init self.mount("https://", HTTPAdapter())

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 155, in init self.init_poolmanager(pool_connections, pool_maxsize, block=pool_block)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 192, in init_poolmanager self.poolmanager = PoolManager(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\poolmanager.py", line 174, in init explicitly.

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3_collections.py", line 51, in init

Full runtime checking of the contents of a Mapping is expensive, so for the

AttributeError: 'RecentlyUsedContainer' object has no attribute 'ContainerCls'`

these are the versions of voyageai

Name: voyageai Version: 0.1.7

thomas0809 commented 5 months ago

Hi,

It looks like a problem in the urllib3 package. I would suggest upgrading the package pip install -U urllib3.

You could also try our latest version pip install -U voyageai.

If the issue persists, please share your environment configuration such as urllib3 version and we can take a look.

GildeshAbhay commented 5 months ago

Tried the first one, same result.

After I tried the second one (pip install -U voyageai), got this error

`[autoreload of voyageai.api_resources.embedding failed: Traceback (most recent call last): File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\IPython\extensions\autoreload.py", line 245, in check superreload(m, reload, self.old_objects) File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\IPython\extensions\autoreload.py", line 394, in superreload module = reload(module) File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\imp.py", line 314, in reload return importlib.reload(module) File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\importlib__init.py", line 169, in reload _bootstrap._exec(spec, module) File "", line 604, in _exec File "", line 848, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\api_resources\embedding.py", line 4, in from voyageai.api_resources import APIResource ImportError: cannot import name 'APIResource' from 'voyageai.api_resources' (C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\api_resources\init__.py) ] Traceback (most recent call last):

File "C:\Users\abhay.saini\AppData\Local\Temp\ipykernel_18680\1374210055.py", line 1, in <cell line: 1> index = VectorStoreIndex(nodes, storage_context=storage_context , embed_model=embed_model)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 75, in init super().init(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\base.py", line 94, in init index_struct = self.build_index_from_nodes(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 308, in build_index_from_nodes return self._build_index_from_nodes(nodes, **insert_kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 280, in _build_index_from_nodes self._add_nodes_to_index(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 233, in _add_nodes_to_index nodes_batch = self._get_node_with_embedding(nodes_batch, show_progress)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\vector_store\base.py", line 141, in _get_node_with_embedding id_to_embed_map = embed_nodes(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\indices\utils.py", line 138, in embed_nodes new_embeddings = embed_model.get_text_embedding_batch(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\dispatcher.py", line 102, in wrapper self.span_drop(*args, id=id, err=e, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\dispatcher.py", line 77, in span_drop h.span_drop(*args, id=id, err=err, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\span_handlers\base.py", line 48, in span_drop span = self.prepare_to_drop_span(*args, id=id, err=err, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\span_handlers\null.py", line 35, in prepare_to_drop_span raise err

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\instrumentation\dispatcher.py", line 100, in wrapper result = func(*args, **kwargs)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\core\base\embeddings\base.py", line 280, in get_text_embedding_batch embeddings = self._get_text_embeddings(cur_batch)

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\embeddings\voyageai\base.py", line 103, in _get_text_embeddings return self._get_embedding(texts, input_type="document")

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\llama_index\embeddings\voyageai\base.py", line 65, in _get_embedding return self._client.embed(

File "C:\Users\abhay.saini\AppData\Local\Programs\Python\Python38\lib\site-packages\voyageai\client.py", line 68, in embed for attempt in self.retry_controller:

AttributeError: 'Client' object has no attribute 'retry_controller'`

thomas0809 commented 5 months ago

From the first line of your code, it seems you are using iPython (or Jupyter notebook), and the autoreload failed.

Please try to restart the iPython kernel and run again.

GildeshAbhay commented 5 months ago

iam running it on Spyder, using python3.8