llm_predictor_gpt4 = LLMPredictor( llm=ChatOpenAI(temperature=0, model_name="gpt-4") )
GPTSimpleVectorIndex(documents_nm_stk,LLMPredictor=llm_predictor_gpt4)
GPTSimpleVectorIndex(documents_nm_stk,llm_predictor=llm_predictor_gpt4)
ValueError: llm must be an instance of langchain.llms.base.LLM
import os from llama_index import GPTSimpleVectorIndex, GPTListIndex, Document, SimpleDirectoryReader, download_loader, LLMPredictor from langchain.llms import OpenAI from pathlib import Path from langchain.chat_models import ChatOpenAI os.environ['OPENAI_API_KEY'] = '' BeautifulSoupWebReader = download_loader("BeautifulSoupWebReader") loader = BeautifulSoupWebReader() #html_links_nm_stk is a list of >700 html links documents_nm_stk = loader.load_data(html_links_nm_stk) #documents_nm_stk loaded successfully #gpt-4 llm_predictor_gpt4 = LLMPredictor( llm=ChatOpenAI(temperature=0, model_name="gpt-4") ) index_nm_stk_gpt4 = GPTSimpleVectorIndex(documents_nm_stk, llm_predictor=llm_predictor_gpt4)
index_nm_stk_gpt4 = GPTSimpleVectorIndex(documents_nm_stk, llm_predictor=llm_predictor_gpt4) Traceback (most recent call last): Cell In[7], line 1 index_nm_stk_gpt4 = GPTSimpleVectorIndex(documents_nm_stk, llm_predictor=llm_predictor_gpt4) File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/vector_store/vector_indices.py:84 in __init__ super().__init__( File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/vector_store/base.py:63 in __init__ super().__init__( File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/base.py:87 in __init__ self._prompt_helper = prompt_helper or PromptHelper.from_llm_predictor( File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/prompt_helper.py:69 in from_llm_predictor llm_metadata = llm_predictor.get_llm_metadata() File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/langchain_helpers/chain_wrapper.py:89 in get_llm_metadata return _get_llm_metadata(self._llm) File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/langchain_helpers/chain_wrapper.py:36 in _get_llm_metadata raise ValueError("llm must be an instance of langchain.llms.base.LLM") ValueError: llm must be an instance of langchain.llms.base.LLM
pip install --upgrade llama_index langchain
llm_predictor_gpt4 = LLMPredictor( llm=ChatOpenAI(temperature=0, model_name="gpt-4") ) index_nm_stk_gpt4 = GPTSimpleVectorIndex(documents_nm_stk, llm_predictor_gpt4) Traceback (most recent call last): Cell In[19], line 5 index_nm_stk_gpt4 = GPTSimpleVectorIndex(documents_nm_stk, llm_predictor_gpt4) File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/vector_store/vector_indices.py:89 in __init__ super().__init__( File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/vector_store/base.py:63 in __init__ super().__init__( File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/base.py:79 in __init__ if index_struct is None and documents is None: ValueError: Only one of documents or index_struct can be provided.
index_nm_stk_gpt4 = GPTSimpleVectorIndex(documents_nm_stk, llm_predictor=llm_predictor_gpt4)
(you have to specify as a kwarg not a positional argument)index_nm_stk_gpt4 = GPTSimpleVectorIndex(documents_nm_stk, llm_predictor=llm_predictor_gpt4) Traceback (most recent call last): Cell In[26], line 1 index_nm_stk_gpt4 = GPTSimpleVectorIndex(documents_nm_stk, llm_predictor=llm_predictor_gpt4) File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/vector_store/vector_indices.py:89 in __init__ super().__init__( File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/vector_store/base.py:63 in __init__ super().__init__( File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/base.py:87 in __init__ self._include_extra_info = include_extra_info File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/indices/prompt_helper.py:69 in from_llm_predictor llm_metadata = llm_predictor.get_llm_metadata() File ~/opt/anaconda3/lib/python3.9/site-packages/llama_index/llm_predictor/base.py:179 in get_llm_metadata return _get_llm_metadata(self._llm) NameError: name '_get_llm_metadata' is not defined
index_nm_stk = GPTSimpleVectorIndex.load_from_disk('index_nm_stk')
NameError: name 'OpenAI' is not defined
llama-index 0.4.39 langchain 0.0.123 openai 0.27.2
response = indexNmstk.query(query, llm_predictor=llm_predictor_gpt4)
llm_predictor_gpt4 = LLMPredictor(llm=ChatOpenAI(temperature=0, model_name="gpt-4")) ... response = indexNmstk.query(query, llm_predictor=llm_predictor_gpt4)
pip install --upgrade langchain llama_index openai
model_name="gpt-3.5-turbo"