Starting off by saying that I'm totally new to this, so super thankful for any help I can get!
I have the following code (from one of the SQL examples from LlamaIndex's website)
engine = create_engine('url')
sql_database = SQLDatabase(engine)
table_node_mapping = SQLTableNodeMapping(sql_database)
index_text = "Some text describing the table"
table_schema_objs = []
table_schema_objs.append(SQLTableSchema(table_name="table_name", context_str=index_text))
index = ObjectIndex.from_objects(
table_schema_objs,
table_node_mapping,
VectorStoreIndex,
)
It works perfectly fine, and I can then use the SQLTableRetrieverQueryEngine
to query the database and get answers. But I want to be able to create the index once so I can reuse it without recreating it every time.
One of the other examples from the website shows how to store the index to a folder like this
parser = SimpleNodeParser()
nodes = parser.get_nodes_from_documents(documents)
index = GPTVectorStoreIndex(nodes)
index.storage_context.persist(persist_dir="index")
I want to do the same thing but with the index I created with ObjectIndex.from_objects
, but I can't seem to figure out how.
I can of course create another type of index, but from the other examples it seemed like they used text to input to create the index from and not objects.