run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
35.22k stars 4.94k forks source link

[Bug]: No module named 'llama_index.llms.openai.base #14785

Open GwangsooHong opened 1 month ago

GwangsooHong commented 1 month ago

Bug Description

The following error occurs with from llama_index.llms.nvidia import NVIDIA

Version

llama_index (0.10.55) llama_index_llms_openai (0.1.25) ,llama-index-llms-nvidia (0.1.4)

Steps to Reproduce

pip install llama-index llama-index-llms-nvidia llama-index-llms-openai

Relevant Logs/Tracbacks

The full log is as follows.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[88], line 1
----> 1 from llama_index.llms.nvidia import NVIDIA

File /opt/conda/lib/python3.11/site-packages/llama_index/llms/nvidia/__init__.py:1
----> 1 from llama_index.llms.nvidia.base import NVIDIA
      3 __all__ = ["NVIDIA"]

File /opt/conda/lib/python3.11/site-packages/llama_index/llms/nvidia/base.py:16
     10 from llama_index.core.bridge.pydantic import PrivateAttr, BaseModel
     11 from llama_index.core.base.llms.generic_utils import (
     12     get_from_param_or_env,
     13 )
---> 16 from llama_index.llms.openai_like import OpenAILike
     18 DEFAULT_MODEL = "meta/llama3-8b-instruct"
     19 BASE_URL = "https://integrate.api.nvidia.com/v1/"

File /opt/conda/lib/python3.11/site-packages/llama_index/llms/openai_like/__init__.py:1
----> 1 from llama_index.llms.openai_like.base import OpenAILike
      3 __all__ = ["OpenAILike"]

File /opt/conda/lib/python3.11/site-packages/llama_index/llms/openai_like/base.py:20
     14 from llama_index.core.constants import DEFAULT_CONTEXT_WINDOW
     15 from llama_index.core.base.llms.generic_utils import (
     16     async_stream_completion_response_to_chat_response,
     17     completion_response_to_chat_response,
     18     stream_completion_response_to_chat_response,
     19 )
---> 20 from llama_index.llms.openai.base import OpenAI, Tokenizer
     21 from transformers import AutoTokenizer
     24 class OpenAILike(OpenAI):

ModuleNotFoundError: No module named 'llama_index.llms.openai.base'; 'llama_index.llms.openai' is not a package
dosubot[bot] commented 1 month ago

@GwangsooHong Hey there! I'm here to help you with any bugs or questions you have. Let's squash this bug together!

The llama_index.llms.openai.base module has been refactored. The correct module path is now llama_index.legacy.llms.openai_like.base:

from llama_index.legacy.llms.openai_like import OpenAILike

__all__ = ["OpenAILike"]

Update your import statements accordingly to resolve the ModuleNotFoundError [1][2].

To continue talking to Dosu, mention @dosu.