I'm building a really smart and well-optimized RAG agent in n8n for a psychotherapist. The idea is that users can share the issues they're facing, and the agent will give them the most accurate and relevant advice. It's trained on a selection of books that I know provide the best information, along with thousands of transcripts that show how those principles are applied in real-life situations.
Here's how it works:
- Understands the User – It first asks about their situation and collects some personal details like age or where they live for personalization. This info is stored in a vectorized chat history.
- Finds Relevant Info – It looks up its knowledgebase and past transcripts to find similar cases and the advice that was given.
- Asks Follow-up Questions – If needed, it asks a few targeted questions to until it has enough relevant context before deciding the most applicable advice to give. These are asked one at a time so the user doesn’t feel overwhelmed.
- Learns Over Time – Users can update the agent on what happened after following the advice, and it keeps track of their situation to improve future responses.
I’ve already set up a basic version where chat history is saved in a Postgres database, user details go into Supabase, and documents are stored in Pinecone for retrieval. However, the agent doesn't always reference its knowledgebase properly. When it does, the advice is somewhat relevant but not as precise or helpful as I’d like.
Im also wondering if its best to use pinecone or supabase to store the literature (mainly pdf ebooks), and if I need to have a few agents doing the work rather than just one.
Does anyone have advice on how to structure and optimize this better? Or would anyone be willing to help me finish setting it up properly so it gives highly accurate and relevant advice?
Cheers
Gregg