0

I am trying to load a Llama index file that I already created and saved to S3. This is the code sample provided by the Llama Index docs (https://gpt-index.readthedocs.io/en/latest/how_to/storage/save_load.html). However, when I use this code to retrieve an index JSON file that I've already saved to S3, I get the error:

Error: 'str' object has no attribute 'get_doc_id'
import boto3
import json
from llama_index import VectorStoreIndex

s3 = boto3.client('s3')

def read_index_file(bucket_name, file_name):
    try:
        response = s3.get_object(Bucket=bucket_name, Key=file_name)
        content = response['Body'].read().decode('utf-8')
        index_data = json.loads(content)
        return index_data
    except Exception as e:
        print("Error reading index file:", str(e))
        return None

bucket_name = 'your_bucket_name'
file_name = 'your_file_name.json'
index_data = read_index_file(bucket_name, file_name)

index = VectorStoreIndex.from_documents(index_data)

The content is loaded fine from S3, it's just the step of loading that index file into a VectorStoreIndex object that's failing. I had it working on a previous version of llama_index, but I can't get this to work.

beachCode
  • 3,202
  • 8
  • 36
  • 69

0 Answers0