pythonlangchainllama-index

ImportError: cannot import name 'GPTSimpleVectorIndex' from 'llama_index'


I am getting an ImportError while using GPTSimpleVectorIndex from the llama-index library. Have installed the latest version of llama-index library and trying to run it on python 3.9.

from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader, LLMPredictor, PromptHelper, ServiceContext
ImportError: cannot import name 'GPTSimpleVectorIndex' from 'llama_index' (E:\Experiments\OpenAI\data anaysis\llama-index-main\venv\lib\site-packages\llama_index\__init__.py

The source code is given below,

import os, streamlit as st

from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader, LLMPredictor, PromptHelper, ServiceContext
from langchain.llms.openai import OpenAI

Solution

  • Try use GPTVectorStoreIndex instead of GPTSimpleVectorIndex:

    from llama_index import GPTVectorStoreIndex, ..