[Question]: 'VectorStoreIndex' object has no attribute 'save' #8567
Replies: 2 comments
-
Hey @freecoffee13, we don't have |
Beta Was this translation helpful? Give feedback.
-
🤖 Hello @freecoffee13, I'm here to help you with your issue. I'm a bot designed to assist with bugs, answer questions, and help you become a contributor while you're waiting for a human maintainer. The error you're encountering is due to the fact that the 'VectorStoreIndex' class does not have a 'save' method. This is why you're seeing the Based on the information from similar issues in the LlamaIndex repository, the 'index.save' method is no longer available in the LlamaIndex API. Instead, you should use the # Persist the index
index.storage_context.persist('saved_index.json') This will save the index to a JSON file named 'saved_index.json'. If you want to save it to a different directory, you can provide the directory path as the argument to the You can refer to the following issues for more details:
I hope this helps! If you have any other questions or need further clarification, feel free to ask. Best, Sources
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Question Validation
Question
i'm coding a chatbot with chat gpt api and i'm stucked in this error:
AttributeError Traceback (most recent call last)
Cell In[11], line 22
19 index.save('index.json')
21 return index
---> 22 a= construct_index("/home/ber/Documentos/docs")
Cell In[11], line 19, in construct_index(directory_path)
15 documentos = SimpleDirectoryReader("/home/ber/Documentos/docs").load_data()
17 index = VectorStoreIndex(nodes=documentos, llm_predictor=llm_predictor, prompt_helper=prompt_helper)
---> 19 index.save('index.json')
21 return index
AttributeError: 'VectorStoreIndex' object has no attribute 'save'
here is the code
import os
import gradio as gr
from llama_index import VectorStoreIndex, SimpleDirectoryReader, ListIndex, LLMPredictor, PromptHelper
from langchain.llms import OpenAI
import openai
#openai.api_key = 'xxxx'
os.environ["OPENAI_API_KEY"] = "xxxx"
#os.environ["xxxx"] = ''
def construct_index(directory_path):
max_input_size = 4096
num_outputs = 512
max_chunk_overlap = 0.9
limite_de_tamanho_do_chunk = 600
def chatbot(input_text):
index = VectorStoreIndex(nodes=SimpleDirectoryReader("index.json").load_data())
response = index.query(input_text, response_mode="compact")
return response.response
Beta Was this translation helpful? Give feedback.
All reactions