chapter ten

10 RAG and agentic apps with LangGraph and Streamlit

 

This chapter covers

  • Developing a chatbot frontend with Streamlit’s chat elements
  • Streamlining an advanced AI app with LangGraph and LangChain
  • How embeddings and vector databases work
  • Augmenting an LLM’s pre-trained knowledge with retrieval-augmented generation (RAG)
  • Enabling an LLM to access and execute real-world actions

Creating a fun and engaging experience, like the trivia game we built in chapter 9, is exciting, but the true power of AI lies in its ability to drive real business value. AI isn’t just about answering questions or generating text; it’s about transforming industries, streamlining operations, and enabling entirely new business models.

But building AI applications that deliver economic value requires more than calling a pre-trained model. To be useful in real-world scenarios, AI must understand the context in which it operates, connect to external data sources, and take meaningful actions. Companies need AI to understand and respond to domain-specific queries, interact with business systems, and provide personalized assistance.

10.1 Nibby: A customer service bot

10.1.1 Stating the concept and requirements

10.1.2 Visualizing the user experience

10.1.3 Brainstorming the implementation

10.1.4 Installing dependencies

10.2 Creating a basic chatbot

10.2.1 Introduction to LangGraph and LangChain

10.2.2 Graphs, nodes, edges, and state

10.2.3 A one-node LLM graph

10.3 Multi-turn conversations

10.3.1 Adding memory to the graph

10.3.2 Displaying the conversation history

10.4 Restricting the bot to customer support

10.4.1 Creating a base prompt

10.4.2 Inserting a base context node in the graph

10.5 Retrieval Augmented Generation

10.5.1 What is Retrieval Augmented Generation?

10.5.2 Implementing RAG in our app

10.6 Turning the bot into an agent