Is it possible to extract either the sql query or the sql result from the QueryPipeline? #12634
Replies: 1 comment 1 reply
-
Hey there, @simontoftnielsen! Great to see you diving into another intriguing puzzle with LlamaIndex. How's everything going on your end? Based on the code you've provided, it seems like you're trying to extract the SQL query or its result from the If you want to extract the SQL query or its result, you'll need to look into the specific modules that handle these tasks. In your case, these modules might be Here's a brief explanation of how you might approach this:
Remember, the QP object is just a framework for executing a series of tasks in a specific order. It doesn't know or care about the specifics of what each task is doing. So, if you want to extract specific information like an SQL query or its result, you'll need to get that from the specific task (module) that handles it. I hope this helps! If you have any more questions or need further clarification, feel free to ask. Sources
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to return the actual result from the sql query to the user.
I am using the QueryPipeline that looks like this:
qp = QP(
modules={
"input": InputComponent(),
"table_retriever": obj_retriever,
"table_output_parser": table_parser_component,
"text2sql_prompt": text2sql_component,
"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,
)
qp.add_chain(["input", "table_retriever", "table_output_parser"])
qp.add_link("input", "text2sql_prompt", dest_key="query_str")
qp.add_link("table_output_parser", "text2sql_prompt", dest_key="schema")
qp.add_chain(
["text2sql_prompt", "text2sql_llm", "sql_output_parser", "sql_retriever"]
)
qp.add_link(
"sql_output_parser", "response_synthesis_prompt", dest_key="sql_query"
)
qp.add_link(
"sql_retriever", "response_synthesis_prompt", dest_key="context_str"
)
qp.add_link("input", "response_synthesis_prompt", dest_key="query_str")
qp.add_link("response_synthesis_prompt", "response_synthesis_llm")
How ever the qp object does not return either the sql query that has been used or the result from the sql query.
Is it possible to somehow extract either of these from the pipeline?
Beta Was this translation helpful? Give feedback.
All reactions