if you set verbose=True
in the constructor, do you see a log like
> Predicted SQL query: ....
in the terminal?
I am struggling to add the verbose mode as NLSQLTableQueryEngine does not accept it
this is my code :
llm = OpenAI(temperature=self.config.temperature, api_base=self.config.mixtral2_api_url)
service_context = ServiceContext.from_defaults(llm=llm)
query_engine = NLSQLTableQueryEngine(
sql_database=self.get_sql_database(),
tables=list(included_tables.views.keys()),
synthesize_response=True,
text_to_sql_prompt=PromptTemplate(prompt_text, template_var_mappings={}),
service_context=service_context)
response = query_engine.query(question )
where can I put verbose=True you think?
query_engine = NLSQLTableQueryEngine(..., verbose=True)
File "C:\Users\guillaume\Documents\GitHub\starboard\src\starboard.py", line 402, in get_database_answer
query_engine = NLSQLTableQueryEngine(
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\guillaume.conda\envs\starboard\Lib\site-packages\llama_index\indices\struct_store\sql_query.py", line 377, in init
super().init(
File "C:\Users\guillaume.conda\envs\starboard\Lib\site-packages\llama_index\indices\struct_store\sql_query.py", line 270, in init
super().init(self._service_context.callback_manager, **kwargs)
TypeError: BaseQueryEngine.init() got an unexpected keyword argument 'verbose'
Seems like the constructor does not accept this parameter
what version of llama-index do you have? I'm looking at the source code right now
ah, yea that version does not appear to have that option
Yea -- I was looking at the latest above. Im assuming you have 0.8.62 due to openai updating after that?
Looking at the source code for 0.8.62 there is another option, but it is much more verbose
import logging
import sys
logging.basicConfig(
stream=sys.stdout, level=logging.DEBUG
)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
yes I dont want to update the openai package yet
we can use debug logging on the logger to see the same log
So this will show the exact string that its running, so we can confirm what it looks like π
interesting. it actually succeeds
but it does another iteration and answer that it failed
hmmm, yea I see it still has an issue running this query
SELECT SUM(Quantity) as TotalDeals
FROM Starboard\_PhysicalMovementsBoughtStockSold
WHERE Type LIKE 'deal%'
Is that valid SQL? Does that work if you run it yourself?
except for the \_ in the table name
there is a backslash that shouldnt be there
if that is the case it comes from my llm not outputting valid sql indeed
I will investigate that. thank you for your debug trick ! very useful!
well I dont know if the backslah is only added in the log or if it is in the query actually
but I will get rid of it!
In the future, I would like to add a hook to pre-process the SQL before running it, just haven't got around to it π
it is already great like that. thanks for this great package !