A customer-support chatbot needs reliable information about the company it represents. A knowledge base supplies that information: here, it is a folder of text articles about products and business practices. The chatbot uses it to answer relevant customer questions, while order tracking and cancellation are separate actions. section 10.1.1 section 10.5.2
A question about fountain pens
An article about fountain-pen maintenance advises cleaning the nib with warm water, using high-quality ink, and storing pens upright. A customer asking how to care for a pen needs that article’s relevant advice, not every support article. section 10.5.2 section 10.5.1
Sending the entire knowledge base with every question can overload the model and raise token costs. Retrieval-augmented generation (RAG) instead finds the relevant parts, adds them to the question’s context, and asks the language model to answer. Finding the right parts is the main challenge. section 10.5.1
To make the articles searchable:
- Load the text files and split them into overlapping chunks. section 10.5.2
- Store the chunks and their embeddings in a Pinecone index, then use similarity search to retrieve chunks for a customer question. section 10.5.2
- Place retrieved excerpts in the chatbot’s instructions. If they do not support a confident answer, direct the customer to a human representative. section 10.5.2
@staticmethod
def augment_node(state: AgentState):
docs = state["retrieved_docs"]
docs_content_list = [doc.page_content for doc in docs]
content = "\n".join(docs_content_list)
new_text = SYS_MSG_AUGMENTATION.replace("{docs_content}", content)
return {"sys_msg_text": BASE_SYS_MSG + "\n\n" + new_text}
The augmentation step joins retrieved document contents and adds them to the system message before the chatbot answers. section 10.5.2









