Skip to content

Retrieval QA History

Retrieval QA History answers a user’s questions with the information in your knowledge base: it finds the passages of your documents related to the question and asks an AI model to answer from them. It also takes into account the earlier messages of the conversation, so it understands follow-up questions like “and on the annual plan?”.

Use it to build a question-and-answer assistant over your manuals, policies or catalogues that keeps the thread of the conversation.

When to use it

  • A support assistant that answers from the product manuals and understands the questions that follow the first one.
  • An internal assistant that answers staff questions about holidays, expenses or remote work from company policies.
  • A sales assistant that answers about prices and terms with the current documentation and can cite where each answer comes from.

Configuration

FieldWhat it does
System PromptThe instructions for the model. It comes with a text that tells it to answer with the information found, in three sentences at most, and to say it doesn’t know if it can’t find it. Adapt it to your case.
InputThe user’s question. Connect it, for example, to a Chat Input.
Return Source DocumentsAdds the references of the documents used at the end of the answer. Default: off.
StreamShows the answer little by little as it is generated. It only has an effect in the chat. Default: on.
Memory top messageHow many earlier messages of the conversation are taken into account when you don’t connect an external memory. Default: 20.
ConnectionWhat to connect
Model (required)An AI model component, for example OpenAI.
Retriever (required)The knowledge base to search: the Retriever output of a component such as Chroma DB or PGVector.
External MemoryOptional. A memory component that keeps the history outside NappAI, for example Postgres Chat Memory or Redis Chat Memory. If you connect none, the history NappAI keeps of the flow’s conversations is used.

Output

  • Text: the answer for the user. Connect it to a Chat Output to show it in the chat.
  • Runnable: the component ready to be run by another one, for example Runnable As Tool so an agent can use it as a tool. Used this way, it does not take the conversation history into account.

Example

Software Abedul wants an assistant that answers its customers with the documentation of its invoicing software:

  1. Load the manuals into a knowledge base, for example Chroma DB, and connect its Retriever output to Retriever.
  2. Connect a Chat Input to Input and a model to Model.
  3. In System Prompt write: “You are Software Abedul’s support assistant. Answer with the information in the manuals; if it isn’t there, offer to open a ticket.”
  4. Turn on Return Source Documents and connect Text to a Chat Output.

When a customer asks “how do I issue a corrective invoice?” and then “and if I already sent it?”, the assistant understands the second question is still about corrective invoices and says which manual the answer comes from.

Good practices

  • Ask in System Prompt for it to say it doesn’t know when the information isn’t in the documents, to avoid made-up answers.
  • Keep the knowledge base up to date: the assistant only knows what your documents contain.