llama_index: [Bug]: AssertionError 2024-12-01 12:51:18.470 Examining the path of torch.classes raised: Tried to instantiate class '__path__._path', but it does not exist! Ensure that it is registered via torch::class_
Bug Description
AssertionError 2024-12-01 12:51:18.470 Examining the path of torch.classes raised: Tried to instantiate class 'path.path’, but it does not exist! Ensure that it is registered via torch::class
Version
python = “3.11” llama-index = “0.11.23”
Steps to Reproduce
python = “^3.11” llama-index = “0.11.23” llama-index-vector-stores-chroma = “0.3.0” llama-index-llms-ollama = “0.3.6”
Relevant Logs/Tracbacks
2024-12-01 12:51:17.157 Uncaught app exception
Traceback (most recent call last):
File "C:\Users\VilvanSS\AppData\Local\pypoetry\Cache\virtualenvs\golden_build-6-JWb2q3-py3.11\Lib\site-packages\streamlit\runtime\scriptrunner\exec_code.py", line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File "C:\Users\VilvanSS\AppData\Local\pypoetry\Cache\virtualenvs\golden_build-6-JWb2q3-py3.11\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 579, in code_to_exec
exec(code, module.__dict__)
File "C:\TestingBot\GB\Hybrid_11_23\chat.py", line 751, in <module>
main()
File "C:\TestingBot\GB\Hybrid_11_23\chat.py", line 386, in main
init_llm_ollama(temperature=temperature)
File "C:\Users\VilvanSS\AppData\Local\pypoetry\Cache\virtualenvs\golden_build-6-JWb2q3-py3.11\Lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 219, in __call__
return self._get_or_create_cached_value(args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VilvanSS\AppData\Local\pypoetry\Cache\virtualenvs\golden_build-6-JWb2q3-py3.11\Lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 242, in _get_or_create_cached_value
return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VilvanSS\AppData\Local\pypoetry\Cache\virtualenvs\golden_build-6-JWb2q3-py3.11\Lib\site-packages\streamlit\runtime\caching\cache_utils.py", line 299, in _handle_cache_miss
computed_value = self._info.func(*func_args, **func_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\TestingBot\GB\Hybrid_11_23\rag_functions.py", line 300, in init_llm_ollama
Settings.llm = llm
^^^^^^^^^^^^
File "C:\Users\VilvanSS\AppData\Local\pypoetry\Cache\virtualenvs\golden_build-6-JWb2q3-py3.11\Lib\site-packages\llama_index\core\settings.py", line 46, in llm
self._llm = resolve_llm(llm)
^^^^^^^^^^^^^^^^
File "C:\Users\VilvanSS\AppData\Local\pypoetry\Cache\virtualenvs\golden_build-6-JWb2q3-py3.11\Lib\site-packages\llama_index\core\llms\utils.py", line 102, in resolve_llm
assert isinstance(llm, LLM)
^^^^^^^^^^^^^^^^^^^^
AssertionError
2024-12-01 12:51:18.470 Examining the path of torch.classes raised: Tried to instantiate class '__path__._path', but it does not exist! Ensure that it is registered via torch::class_
Stopping...
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20
The error you’re encountering,
ValueError: "CustomOllama" object has no field "headers", suggests that theCustomOllamaclass is likely using a library like Pydantic, which enforces strict attribute definitions. This means that attributes must be explicitly defined in the class, typically using Pydantic’sBaseModelor similar.To resolve this issue, you should explicitly define the
headersattribute in yourCustomOllamaclass. Here’s how you can modify your class to include theheadersattribute:In this modification:
CustomOllamaclass inherits fromBaseModel, which is a common pattern when using Pydantic.headersattribute is defined as a field with a default value of an empty dictionary.__init__method is adjusted to usesuper().__init__(**data)to initialize the Pydantic model with the provided data.This should resolve the
ValueErrorby ensuring thatheadersis a recognized attribute of theCustomOllamaclass.To continue talking to Dosu, mention @dosu.