Is there any way I can add retry logic to an advanced text-to-sql pipeline? My pipeline is defined below,which is straight from llamaindex docs:
https://docs.llamaindex.ai/en/stable/examples/pipeline/query_pipeline_sql/?h=table+parser#define-expanded-query-pipelinefrom llama_index.core.query_pipeline import (
QueryPipeline as QP,
Link,
InputComponent,
CustomQueryComponent,
)
qp = QP(
modules={
"input": InputComponent(),
"table_retriever": obj_retriever,
"table_output_parser": table_parser_component,
"text2sql_prompt": text2sql_prompt,
"text2sql_llm": llm,
"sql_output_parser": sql_parser_component,
"sql_retriever": sql_retriever,
"response_synthesis_prompt": response_synthesis_prompt,
"response_synthesis_llm": llm,
},
verbose=True,
)
The links and chains are also taken straight from the docs.
I want to implement retry logic such that if the SQL statement and its result is incorrect (incorrect syntax or doesn't address the prompt, for example), it should like "fix" the SQL statement and check it & the results again, and keep doing it until it is correct. (maybe max 3 tries). The problem is I am trying to follow the documentation here:
https://docs.llamaindex.ai/en/stable/examples/agent/agent_runner/query_pipeline_agent/#setup-simple-retry-agent-pipeline-for-text-to-sqlBut I am unclear as to how exactly I can add this to my already defined pipeline (above). Any help is appreciated, thanks