Find answers from the community

Home
Members
PREDATOR
P
PREDATOR
Offline, last seen 3 months ago
Joined September 25, 2024
what is this error? -


---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_20692\960662579.py in <module>
----> 1 from llama_index.retrievers import NLSQLRetriever
2
3 # default retrieval (return_raw=True)
4 nl_sql_retriever = NLSQLRetriever(
5 sql_database, tables=["city_stats"], return_raw=True

ImportError: cannot import name 'NLSQLRetriever' from 'llama_index.retrievers' (C:\Users\alens\AppData\Roaming\Python\Python39\site-packages\llama_index\retrievers__init__.py)
5 comments
k
P
I'm trying to add context to a structured table using the same method as shown below, but it doesn't seem to work. Has anyone successfully injected context to a sql table?


Plain Text
# manually set context text
city_stats_text = (
    "This table gives information regarding the population and country of a given city.\n"
    "The user will query with codewords, where 'foo' corresponds to population and 'bar'"
    "corresponds to city."
)

from llama_index.objects import SQLTableNodeMapping, SQLTableSchema

table_node_mapping = SQLTableNodeMapping(sql_database)
table_schema_objs = [
    (SQLTableSchema(table_name="city_stats", context_str=city_stats_text))
]




Sources:
https://github.com/jerryjliu/llama_index/blob/main/docs/examples/index_structs/struct_indices/SQLIndexDemo.ipynb
https://gpt-index.readthedocs.io/en/latest/end_to_end_tutorials/structured_data/sql_guide.htm
14 comments
P
L
P
PREDATOR
·

Error

Hi Everyone, I need help resolving error while running this -

from llama_index import LLMPredictor, ServiceContext, SQLDatabase, VectorStoreIndex from llama_index.indices.struct_store import SQLTableRetrieverQueryEngine from llama_index.objects import SQLTableNodeMapping, ObjectIndex, SQLTableSchema from langchain import OpenAI

ERROR Message -
3 comments
L
P
Hi, how to deal with the token limit error?

I have a large dataset, for example amazon sales data. If I use text-to-sql it will show a token limit error right? How to resolve this issue?


My aim is to create a chatbot for amazon sales data, query and visualise on top of it. I'm planning to use openai api along with the text-to-sql llama index function.

Any help is appreciated.
1 comment
L