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

[Question]: #14602

Open
1 task done
medhsv opened this issue Jul 6, 2024 · 6 comments
Open
1 task done

[Question]: #14602

medhsv opened this issue Jul 6, 2024 · 6 comments
Labels
question Further information is requested

Comments

@medhsv
Copy link

medhsv commented Jul 6, 2024

Question Validation

  • I have searched both the documentation and discord for an answer.

Question

Does anyone have fix to the following issue:

ImportError Traceback (most recent call last)
in <cell line: 16>()
14 #from llama_index.prompts import SimpleInputPrompt
15 # Import the llama index HF Wrapper
---> 16 from llama_index.llms import HuggingFaceLLM
17 # Bring in embeddings wrapper
18 from llama_index.embeddings import LangchainEmbedding

ImportError: cannot import name 'HuggingFaceLLM' from 'llama_index.llms' (unknown location)

I need it fixed urgently
searched everywhere no fix found

@medhsv medhsv added the question Further information is requested label Jul 6, 2024
Copy link

dosubot bot commented Jul 6, 2024

Hey there, @medhsv! 👋 I'm here to help you out with your coding conundrum. I'm a bot designed to assist with bug fixes, answer questions, and even guide you on becoming a contributor. Let's squash this bug together!

You should import HuggingFaceInferenceAPI from the llama_index.llms.huggingface_api module instead:

from llama_index.llms.huggingface_api import HuggingFaceInferenceAPI

This should resolve the ImportError you are experiencing [1][2][3].

To continue talking to Dosu, mention @dosu.

@medhsv
Copy link
Author

medhsv commented Jul 6, 2024

I am also facing the following issue:

ImportError Traceback (most recent call last)
in <cell line: 12>()
10 from llama_index.embeddings.langchain import LangchainEmbedding
11
---> 12 from llama_index import ServiceContext, set_global_service_context
13
14 # Import transformer classes for generation

ImportError: cannot import name 'ServiceContext' from 'llama_index' (unknown location)

Copy link

dosubot bot commented Jul 6, 2024

You should import ServiceContext from llama_index.legacy.service_context instead:

from llama_index.legacy.service_context import ServiceContext
from llama_index import set_global_service_context

This should resolve the ImportError you are experiencing [1].

To continue talking to Dosu, mention @dosu.

@medhsv
Copy link
Author

medhsv commented Jul 6, 2024

For

You should import ServiceContext from llama_index.legacy.service_context instead:

from llama_index.legacy.service_context import ServiceContext
from llama_index import set_global_service_context

This should resolve the ImportError you are experiencing [1].

To continue talking to Dosu, mention @dosu.

For this fix issued
I am facing the following error

[nltk_data] Downloading package stopwords to
[nltk_data] /usr/local/lib/python3.10/dist-
[nltk_data] packages/llama_index/legacy/_static/nltk_cache...
[nltk_data] Unzipping corpora/stopwords.zip.
[nltk_data] Downloading package punkt to
[nltk_data] /usr/local/lib/python3.10/dist-
[nltk_data] packages/llama_index/legacy/_static/nltk_cache...
[nltk_data] Unzipping tokenizers/punkt.zip.

ImportError Traceback (most recent call last)
in <cell line: 20>()
18
19 from llama_index.legacy.service_context import ServiceContext
---> 20 from llama_index import set_global_service_context
21
22

ImportError: cannot import name 'set_global_service_context' from 'llama_index' (unknown location)

Copy link

dosubot bot commented Jul 6, 2024

To resolve the ImportError for set_global_service_context, you should import it from the llama_index.legacy.service_context module:

from llama_index.legacy.service_context import ServiceContext, set_global_service_context

This should fix the import error you are encountering [1].

To continue talking to Dosu, mention @dosu.

@logan-markewich
Copy link
Collaborator

@medhsv you are using several old imports from v0.9.x, which no longer work. In v0.10
.x, every integration is a package. Check out the latest docs for installs and imports

So far from what I read, you need

pip install llama-index llama-index-llms-huggingface

from llama_index.llms.huggingface import HuggingFaceLLM
from llama_index.core import ServiceContext, set_global_service_context 

Note that service context is deprecated, but still works (again, do checkout the docs at https://docs.llamaindex.ai)

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

No branches or pull requests

2 participants