-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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]: Settings.context_window Attribute error: NoneType object has no attribute context window. #17564
Comments
Hey @ArshiaSangwan! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this issue together! The error occurs because the The from llama_index.llms.openai import OpenAI
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.core.node_parser import SentenceSplitter
from llama_index.core import Settings
Settings.llm = OpenAI(model="gpt-3.5-turbo")
Settings.embed_model = OpenAIEmbedding(model="text-embedding-3-small")
Settings.node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=20)
Settings.num_output = 512
Settings.context_window = 3900 Make sure the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Works fine for me? Can you give actual code to reproduce? For example |
Thank you for the prompt response @logan-markewich ! #importing the necessary libraries Load environment variablesload_dotenv() llm_model = ChatOpenAI(model='o1-mini', base_url=os.environ['OPENAI_API_BASE'], api_key=os.environ['OPENAI_API_KEY']) Settings._llm = llm_model Debugprint("BEFORE") print("SUCCESS") |
I have the same issue. For some reason setting the context_window before the LLM resolves the issue, which is weird. Settings._llm = llm_model -> AttributeError Traceback (most recent call last) File ~/miniforge3/envs/kg_rag_gr_120/lib/python3.12/site-packages/llama_index/core/settings.py:220, in _Settings.num_output(self, num_output) File ~/miniforge3/envs/kg_rag_gr_120/lib/python3.12/site-packages/llama_index/core/settings.py:201, in _Settings.prompt_helper(self) File ~/miniforge3/envs/kg_rag_gr_120/lib/python3.12/site-packages/llama_index/core/indices/prompt_helper.py:120, in PromptHelper.from_llm_metadata(cls, llm_metadata, chunk_overlap_ratio, chunk_size_limit, tokenizer, separator) AttributeError: 'NoneType' object has no attribute 'context_window' Whereas the following: Settings.num_output = 512 works fine. Something seems a bit off here? |
Question Validation
Question
I am getting an AttributeError: 'NoneType' object has no attribute 'context_window' when using "Settings.context_window = 3900" with v 0.12.11 while implementing GraphRAG with Llama-Index.
I am importing the Settings module. Further, when I am using the existing suggested solution of ServiceContext, I get an error stating that it has been deprecated in the latest version of llama-index.
Any help would be appreciated.
The text was updated successfully, but these errors were encountered: