Search Postgresql Archives

Formulating SQL queries via Retrieval Augmented Generation (RAG).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

I have managed to use RAG to query data in a PostgreSQL table using Python and the lanchain_community module.

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux