Replies: 8 comments
-
🤖 Hello, To have the Here's how you can do it: def _query(self, query_bundle: QueryBundle) -> Response:
"""Answer a query."""
table_desc_str = self._get_table_context(query_bundle)
logger.info(f"> Table desc str: {table_desc_str}")
response_str = self._service_context.llm_predictor.predict(
self._text_to_sql_prompt,
query_str=query_bundle.query_str,
schema=table_desc_str,
dialect=self._sql_database.dialect,
)
sql_query_str = self._parse_response_to_sql(response_str)
logger.debug(f"> Predicted SQL query: {sql_query_str}")
# Comment out the line that executes the SQL query
# raw_response_str, metadata = self._sql_database.run_sql(sql_query_str)
# metadata["sql_query"] = sql_query_str
# Return the SQL query string instead of executing it
response = Response(response=sql_query_str, metadata={})
return response This modification will make the You can find the original Please let me know if you have any other questions or need further clarification. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Shouldn’t there a be a feature that allows post processing every sql query before executing it on database ? This will help to add any custom logic like data authorisation, additional changes specific to sql dialect.. |
Beta Was this translation helpful? Give feedback.
-
@vp999 yea the bot is wrong Simply set
|
Beta Was this translation helpful? Give feedback.
-
synthesize_response=False doesnt help .. it still executes the sql .. |
Beta Was this translation helpful? Give feedback.
-
Oh whoops, my brain went to another thought (stopping the natural language generation) Turns out the bot was smarter than me. There's no option for it currently. Would be welcome to having a PR though! |
Beta Was this translation helpful? Give feedback.
-
The sql will always get ran currently |
Beta Was this translation helpful? Give feedback.
-
Yes .. thats where we need a hook for modifying the sql before executing .. |
Beta Was this translation helpful? Give feedback.
-
Pull request #9422 @Disiok / @azurewtl : I would appreciate if you can review, try and merge it. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Question Validation
Question
i am using NLSQLTableQueryEngine with llamacpp as backend on azure notebook. The query_engine.query() returns results as well as sql statement. how do i restrict it to return only final sql and not to execute it?
Beta Was this translation helpful? Give feedback.
All reactions