----------------------
The error message you're seeing is an
ImportError
, which means that Python is unable to import the specified module or function. In this case, it's trying to import
NLSQLRetriever
from
llama_index.retrievers
, but it can't find it.
Based on the information provided in the extracts, it seems that
NLSQLRetriever
is not a valid class or function in the
llama_index.retrievers
module. Instead, you might want to use
SQLTableRetrieverQueryEngine
from
llama_index.indices.struct_store
as shown in the
documentation () or
SQLJoinQueryEngine
from
llama_index.query_engine
as shown in the
github notebook ().
Here's an example of how you might use
SQLTableRetrieverQueryEngine
:
from llama_index.indices.struct_store import SQLTableRetrieverQueryEngine
query_engine = SQLTableRetrieverQueryEngine(
sql_database, obj_index.as_retriever(similarity_top_k=1)
)
response = query_engine.query("Which city has the highest population?")
print(response)
Please replace
sql_database
and
obj_index
with your actual SQL database and object index. If you're still having trouble, I recommend checking the LlamaIndex documentation or the source code to ensure you're using the correct classes and functions.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------