SQL Join Query Engine#

SQL Join query engine.

class llama_index.query_engine.sql_join_query_engine.SQLAugmentQueryTransform(llm: Optional[Union[LLMPredictor, LLM]] = None, sql_augment_transform_prompt: Optional[BasePromptTemplate] = None, check_stop_parser: Optional[Callable[[QueryBundle], bool]] = None)#

SQL Augment Query Transform.

This query transform will transform the query into a more specific query after augmenting with SQL results.

Parameters
  • llm (LLM) โ€“ LLM to use for query transformation.

  • sql_augment_transform_prompt (BasePromptTemplate) โ€“ PromptTemplate to use for query transformation.

  • check_stop_parser (Optional[Callable[[str], bool]]) โ€“ Check stop function.

as_query_component(partial: Optional[Dict[str, Any]] = None, **kwargs: Any) QueryComponent#

Get query component.

check_stop(query_bundle: QueryBundle) bool#

Check if query indicates stop.

get_prompts() Dict[str, BasePromptTemplate]#

Get a prompt.

run(query_bundle_or_str: Union[str, QueryBundle], metadata: Optional[Dict] = None) QueryBundle#

Run query transform.

update_prompts(prompts_dict: Dict[str, BasePromptTemplate]) None#

Update prompts.

Other prompts will remain in place.

class llama_index.query_engine.sql_join_query_engine.SQLJoinQueryEngine(sql_query_tool: QueryEngineTool, other_query_tool: QueryEngineTool, selector: Optional[Union[LLMSingleSelector, PydanticSingleSelector]] = None, service_context: Optional[ServiceContext] = None, sql_join_synthesis_prompt: Optional[BasePromptTemplate] = None, sql_augment_query_transform: Optional[SQLAugmentQueryTransform] = None, use_sql_join_synthesis: bool = True, callback_manager: Optional[CallbackManager] = None, verbose: bool = True)#

SQL Join Query Engine.

This query engine can โ€œJoinโ€ a SQL database results with another query engine. It can decide it needs to query the SQL database or the other query engine. If it decides to query the SQL database, it will first query the SQL database, whether to augment information with retrieved results from the other query engine.

Parameters
  • sql_query_tool (QueryEngineTool) โ€“ Query engine tool for SQL database. other_query_tool (QueryEngineTool): Other query engine tool.

  • selector (Optional[Union[LLMSingleSelector, PydanticSingleSelector]]) โ€“ Selector to use.

  • service_context (Optional[ServiceContext]) โ€“ Service context to use.

  • sql_join_synthesis_prompt (Optional[BasePromptTemplate]) โ€“ PromptTemplate to use for SQL join synthesis.

  • sql_augment_query_transform (Optional[SQLAugmentQueryTransform]) โ€“ Query transform to use for SQL augmentation.

  • use_sql_join_synthesis (bool) โ€“ Whether to use SQL join synthesis.

  • callback_manager (Optional[CallbackManager]) โ€“ Callback manager to use.

  • verbose (bool) โ€“ Whether to print intermediate results.

as_query_component(partial: Optional[Dict[str, Any]] = None, **kwargs: Any) QueryComponent#

Get query component.

get_prompts() Dict[str, BasePromptTemplate]#

Get a prompt.

update_prompts(prompts_dict: Dict[str, BasePromptTemplate]) None#

Update prompts.

Other prompts will remain in place.