У меня есть следующий код (из одного из примеров SQL из веб-сайт LlamaIndex)
Код: Выделить всё
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,
)
Один из других примеров с веб-сайта показывает, как сохранить индекс в папке. вот так
Код: Выделить всё
parser = SimpleNodeParser()
nodes = parser.get_nodes_from_documents(documents)
index = GPTVectorStoreIndex(nodes)
index.storage_context.persist(persist_dir="index")
Я, конечно, могу создать другой тип индекса, но из других примеров видно, что для создания индекса для ввода использовался текст, а не объекты.
Подробнее здесь: https://stackoverflow.com/questions/766 ... ecreate-it
Мобильная версия