Predefined WHERE
statements to NLSQLTableQueryEngine
#14934
Replies: 1 comment 4 replies
-
Hey @ashishsurya! 👋 I'm here to help you out with any issues or questions you have. I'm a bot designed to assist you while waiting for a human maintainer. To add a set of predefined Here's an example of how you can do this: class NLSQLTableQueryEngine(BaseSQLTableQueryEngine):
"""
Natural language SQL Table query engine.
Read NLStructStoreQueryEngine's docstring for more info on NL SQL.
"""
def __init__(
self,
sql_database: SQLDatabase,
text_to_sql_prompt: Optional[BasePromptTemplate] = None,
context_query_kwargs: Optional[dict] = None,
synthesize_response: bool = True,
response_synthesis_prompt: Optional[BasePromptTemplate] = None,
tables: Optional[Union[List[str], List[Table]]] = None,
service_context: Optional[ServiceContext] = None,
context_str_prefix: Optional[str] = None,
sql_only: bool = False,
verbose: bool = False,
**kwargs: Any,
) -> None:
"""Initialize params."""
# Add predefined WHERE statements to context_query_kwargs
if context_query_kwargs is None:
context_query_kwargs = {}
context_query_kwargs['where_statements'] = "your_predefined_where_statements"
self._sql_retriever = NLSQLRetriever(
sql_database,
text_to_sql_prompt=text_to_sql_prompt,
context_query_kwargs=context_query_kwargs,
tables=tables,
context_str_prefix=context_str_prefix,
service_context=service_context,
sql_only=sql_only,
verbose=verbose,
)
super().__init__(
synthesize_response=synthesize_response,
response_synthesis_prompt=response_synthesis_prompt,
service_context=service_context,
verbose=verbose,
**kwargs,
)
@property
def sql_retriever(self) -> NLSQLRetriever:
"""Get SQL retriever."""
return self._sql_retriever Replace |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to add a set of
WHERE
statements to the generation ofSQL Query
by NLSQLTableQueryEngineCan anyone help me how to achieve this
Thankyou
Beta Was this translation helpful? Give feedback.
All reactions