Hey everyone! I'm running into issues building the links in my error-correction text-to-SQL agentic pipeline (based on the query pipeline documentation but different). I'm getting
ValueError: too many values to unpack (expected 2)
when running the link between response synthesis prompt and the llm, but all fixes I've tried have resulted in even more errors. Here's the relevant code:
llm = OpenAI(model='gpt-3.5-turbo', temperature = 0.0)
s_sql_retriever = SQLRetriever(sql_database)
# Needed to make function to output str
def s_sql_retriever_fn(task: Task, state: Dict[str, Any], sql_query: str) -> str:
"""Function to run the retriever."""
node_with_score = s_sql_retriever.retrieve(sql_query)
metadata = node_with_score[0].node.metadata
output = {"result": metadata['result'], "col_keys": metadata['col_keys']}
output_str = f"Retrieved columns: {output.get('col_keys', [])}\n SQL Response: {output.get('result', [])}"
return output_str
s_sql_retriever_component = AgentFnComponent(fn=s_sql_retriever_fn)
s_response_synthesis_prompt_str = (
[instructions redacted]
"Query: {query_str}\n"
"SQL: {sql_query}\n"
"{sql_result_and_col_keys_str}\n"
# "Retrieved columns: {retrieved_cols}\n"
# "SQL Response: {sql_response}\n"
"Response: "
)
s_response_synthesis_prompt = PromptTemplate(
s_response_synthesis_prompt_str
)
s_agent_qp = QP(
modules={
"input": s_agent_input_component,
"table_retriever": s_obj_retriever_component,
"table_output_parser": s_table_parser_component,
"retry_prompt": s_prompt,
"llm": llm,
"sql_output_parser": s_parser_component,
"sql_retriever": s_sql_retriever_component,
"response_synthesis_prompt": s_response_synthesis_prompt,
"response_synthesis_llm": llm,
# "output_component": s_agent_output_component,
},
verbose=True,
)
Reached character limit so code/info continued in reply message ⬇️