liveBook · Manning

Chapter 8: Applications and Agents: Building an interactive experience

What you will learn in chapter 8 of LLMs in Production

The chapter introduces the shift from building and deploying LLMs to creating user-facing applications, including edge applications and agents.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces the shift from building and deploying LLMs to creating user-facing applications, including edge applications and agents.

Key terms: LLM service, delightful experience, application, edge devices, GPU, LLM agents, multistep problems, role, request

8.1 Building an application with RAG

Defines an LLM application as the user-facing client and explains why a simple chat interface needs additional features to become a good user experience.

Key terms: LLM application, frontend, LLM Service, client, chatbox, input field, send button, text field, timeout error, streaming responses

8.1.1 Streaming on the frontend

This section shows how a minimal browser app displays an LLM response as it arrives, and why client-side streaming improves the chat experience.

Key terms: StreamingResponse, ReadableStream, sendToServer, client side, streaming on the client side, instant feedback, stop generation, reprompt, HTML, CSS

8.1.2 Keeping a history

The section adds conversation history to an interactive LLM app and explains how to manage that history when it becomes too long.

Key terms: chat history, prompts, responses, context, Streamlit, chat_input, chat_message, session_state, chat_history, streaming

8.1.3 Chatbot interaction features

The section explains interaction features that make LLM chatbots more usable and shows how Gradio can provide a streaming chat interface with several controls built in.

Key terms: fallback response, Submit button, chat history, Stop button, output per token, Retry button, Delete button, temperature, soft delete, feedback form

8.1.4 Token counting

Token counting helps an LLM application warn users before prompts exceed limits and adjust how much retrieved context it adds.

Key terms: submitted tokens, token limits, prompts, Q&A bot, search results, retrieval-augmented generation (RAG), context, tiktoken, BPE tokenizer, OpenAI’s encoders

8.1.5 RAG applied

This section contrasts frontend and backend RAG, then shows how to use an existing vector store to augment queries in an LLM application.

Key terms: RAG, frontend, backend, vector database, prompt injection, business context, finetune, run time, hallucinations, query augmentation

8.2 Edge applications

This section explains why running an LLM inside an edge application is challenging and demonstrates a llama.cpp workflow for obtaining and running a quantized model locally.

Key terms: edge device, local environment, accelerator, GPU, llama.cpp, GGUF, GGML, bindings, convert script, WizardCoder-7B

8.3 LLM agents

This section explains how LLM agents combine a model, memory, and tools to attempt multistep tasks, then demonstrates how to build them and why they remain unreliable.

Key terms: LLM agents, memory, external data retrieval tools, memory buffer, memory summarization, structured memory storage, context limits, lost in the middle, LangChain, Duck Duck Go search tool

8.4 Summary

The chapter summary identifies the features that make LLM applications more usable, then highlights edge deployment and the promise and difficulty of agents.

Where this is used later

Concepts explained in this chapter

← Chapter 7: Prompt engineering: Becoming an LLM whisperer Chapter 9: Creating an LLM project: Reimplementing Llama 3 →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.