9 Creating an agentic RAG-based chatbot
This chapter covers
- Using DSPy for Retrieval Augmented Generation
- Agents and the ReAct methodology
- Agentic RAG
- DSPy’s support for memory and long-running conversations
So far, we’ve covered the most important ideas in DSPy and described how we can create, evaluate, and optimize DSPy-based applications. We’re now ready to create more sophisticated and realistic systems that you’ll likely need in research or work environments. This includes creating RAG-based applications, agents, and systems that can maintain conversations over long periods of time. DSPy supports all of these systems, as well as combining them to create powerful applications, including fully functional chatbots.
We’ll look first at RAG applications, which allow us to work with LMs so that they can respond to queries even when doing so requires information they didn’t see during their training. For example, a company chatbot can accept questions from customers about the company (related to its policies, products, or services), such as “Can I return a coffee maker I bought if it’s unused but the box is opened?” The chatbot may make one or more LM calls to answer these questions, but the LMs won’t, on their own, have any way to know the answer.