# Insert documents into vector index # Each document has metadata of the city attached for city, wiki_doc in zip(cities, wiki_docs): nodes = node_parser.get_nodes_from_documents([wiki_doc]) # add metadata to each node for node in nodes: node.extra_info = {"title": city} vector_index.insert_nodes(nodes)
python3 main.py dict_keys(['city_stats']) [('Toronto', 2930000, 'Canada'), ('Tokyo', 13960000, 'Japan'), ('Berlin', 3645000, 'Germany')] Traceback (most recent call last): File "/home/bi-ai/ai/txt-to-sql/main.py", line 107, in <module> node.extra_info = {"title": city} File "pydantic/main.py", line 357, in pydantic.main.BaseModel.__setattr__ ValueError: "TextNode" object has no field "extra_info"
ython3 main.py dict_keys(['city_stats']) [('Toronto', 2930000, 'Canada'), ('Tokyo', 13960000, 'Japan'), ('Berlin', 3645000, 'Germany')] Upserted vectors: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 17/17 [00:04<00:00, 4.15it/s] Upserted vectors: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 18/18 [00:02<00:00, 7.85it/s] Upserted vectors: 100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 11/11 [00:02<00:00, 4.62it/s] <class 'llama_index.indices.struct_store.sql_query.NLStructStoreQueryEngine'> Traceback (most recent call last): File "/home/bi-ai/ai/txt-to-sql/main.py", line 157, in <module> query_engine = SQLAutoVectorQueryEngine( File "/home/bi-ai/.local/lib/python3.10/site-packages/llama_index/query_engine/sql_vector_query_engine.py", line 94, in __init__ raise ValueError( ValueError: sql_query_tool.query_engine must be an instance of BaseSQLTableQueryEngine or NLSQLTableQueryEngine
python3 main.py dict_keys(['city_stats']) [('Toronto', 2930000, 'Canada'), ('Tokyo', 13960000, 'Japan'), ('Berlin', 3645000, 'Germany')] Traceback (most recent call last): File "/home/bi-ai/ai/txt-to-sql/main.py", line 99, in <module> sql_query_engine = BaseSQLTableQueryEngine([], sql_database, table_name="city_stats") TypeError: Can't instantiate abstract class BaseSQLTableQueryEngine with abstract method _get_table_context
from llama_index import set_global_service_context set_global_service_context(service_context)