I am not sure if this is the right place to post a PostgreSQL + Retrieval Augmented Generation (RAG) question, but I have tried other sites but I did not receive any response.
But I have been struggling for weeks trying to find a solution to using RAG to perform WITH RECURSIVE CTE on two tables (modeling node and edge graph data).
The SQL queries generated by RAG for this graph data model are error prone.
Is there an example somewhere where RAG has been used to successfully generate WITH RECURSIVE CTE on two table graph data?
Below is the main code section I am using to perform RAG on PostgreSQL.
llm = ChatGroq(model="mixtral-8x7b-32768", temperature=0);
chain = (
RunnablePassthrough.assign(query=sql_chain).assign(
schema=lambda _: db.get_table_info(),
response=lambda vars: db.run(vars["query"]),
)
| prompt
| llm
)
response_obj: langchain_core.messages.ai.AIMessage=chain.invoke({
"question": user_query_str,
"chat_history": chat_history_list,
});
Any pointers are welcome.
-Allan