SQL Query Engine
Default query for GPTSQLStructStoreIndex.
- class llama_index.indices.struct_store.sql_query.GPTNLStructStoreQueryEngine(index: GPTSQLStructStoreIndex, text_to_sql_prompt: Optional[Prompt] = None, context_query_kwargs: Optional[dict] = None, synthesize_response: bool = True, response_synthesis_prompt: Optional[Prompt] = None, **kwargs: Any)
GPT natural language query engine over a structured database.
Given a natural language query, we will extract the query to SQL. Runs raw SQL over a GPTSQLStructStoreIndex. No LLM calls are made during the SQL execution. NOTE: this query cannot work with composed indices - if the index contains subindices, those subindices will not be queried.
- Parameters
index (GPTSQLStructStoreIndex) – A GPT SQL Struct Store Index
text_to_sql_prompt (Optional[Prompt]) – A Text to SQL Prompt to use for the query. Defaults to DEFAULT_TEXT_TO_SQL_PROMPT.
context_query_kwargs (Optional[dict]) – Keyword arguments for the context query. Defaults to {}.
synthesize_response (bool) – Whether to synthesize a response from the query results. Defaults to True.
response_synthesis_prompt (Optional[Prompt]) – A Response Synthesis Prompt to use for the query. Defaults to DEFAULT_RESPONSE_SYNTHESIS_PROMPT.
- property service_context: ServiceContext
Get service context.
- class llama_index.indices.struct_store.sql_query.GPTSQLStructStoreQueryEngine(index: GPTSQLStructStoreIndex, sql_context_container: Optional[SQLContextContainerBuilder] = None, **kwargs: Any)
GPT SQL query engine over a structured database.
Runs raw SQL over a GPTSQLStructStoreIndex. No LLM calls are made here. NOTE: this query cannot work with composed indices - if the index contains subindices, those subindices will not be queried.