Final Project: Build a Multi-Step Research Assistant with LangChain and LangGraph
Combine everything from this course, chains, retrieval, tools, and LangGraph, into one working assistant: given a question, it should decide whether it needs to search for more information, retrieve from a small local knowledge base, and produce a final grounded answer.
Requirements
- Set up a real API key (OpenAI, or any provider LangChain supports) and install
langchain,langchain-openai(or your provider's package), andlanggraph. - Build a small local knowledge base (3-5 short text documents on any topic you like) and set up a retriever for it, using the text splitting and vector store pattern from the Retrieval lesson.
- Define a
TypedDictstate with at least aquestion, acontext, and ananswerfield. - Build a LangGraph graph with at least three nodes: one that retrieves context for the question, one that decides (via a conditional edge) whether the retrieved context is sufficient or another retrieval pass is needed, and one that generates the final answer using an LCEL chain (prompt | model | parser) grounded in the retrieved context.
- Compile and run the graph on at least three different questions, one that's clearly answerable from your knowledge base, and one that isn't, confirm the assistant behaves sensibly in both cases (e.g. says it doesn't know, rather than making something up).
Stretch goals
- Add a tool (e.g. a calculator, or a fake "current date" function) and a node that lets the model call it when relevant, on top of retrieval.
- Add a loop limit (a step counter in state) so a conditional edge can't send the graph back to retrieval forever.
- Visualize your graph with
app.get_graph().print_ascii()and include it in your submission.
Submit a link to your finished project (a repo or gist) below, an instructor will review it before you can mark this lesson complete.