# Revision: Cheat Sheet and Self-Check — LangChain / LlamaIndex

Source: https://www.geekswithgeeks.com/en/langchain-llamaindex/z-revision

> Review the key ideas of the whole course.

## Cheat sheet

**Landscape**: frameworks supply reusable plumbing; LangChain composes steps, LlamaIndex connects data; install only the packages you need; pin versions. **LangChain core**: `ChatPromptTemplate`, chat models, `StrOutputParser`/`PydanticOutputParser`, the `|` operator builds a `RunnableSequence`; every runnable has `invoke`, `batch`, `stream`; `RunnableLambda`, `RunnableParallel`, `RunnablePassthrough`. **Reliability**: `@tool` from docstring and hints, `RunnableBranch` routing, `.with_retry`, `.with_fallbacks`, callbacks and tracing, chat history by session. **Retrieval**: Documents, splitters with overlap, embeddings, vector stores, retrievers, a RAG chain of context + question, filters, MMR, reranking. **LlamaIndex**: Document → Node → `VectorStoreIndex` → retriever → query engine with `source_nodes`; set `Settings`; persist and reload. **Agents**: tool-calling loop with limits; LangGraph for stateful flows, checkpoints and approvals; guardrails. **Ship**: fake-model unit tests, evaluation datasets, traces, cost and latency control, secrets, pinned dependencies; drop the framework when it adds nothing.

**Quiz:** Your chain's JSON parsing sometimes fails because the model adds extra text. What is the most robust fix?

- [x] Use native structured output or a Pydantic parser, validate, and retry on failure
- [ ] Ignore the errors
- [ ] Increase chunk size
- [ ] Remove the parser

*Answer:* Use native structured output or a Pydantic parser, validate, and retry on failure. Constrained output plus validation and retry handles stray text.

**Quiz:** Which stage of a RAG app most often explains a wrong answer?

- [ ] The Python version string
- [ ] The font of the UI
- [x] Retrieval did not return the relevant passage
- [ ] The length of the repo name

*Answer:* Retrieval did not return the relevant passage. If the evidence is missing from the prompt, the model cannot use it.

**Quiz:** What should an agent loop always include?

- [ ] Write access to every system
- [ ] Unlimited iterations
- [x] Step and budget limits, argument validation and logging of tool calls
- [ ] No tests

*Answer:* Step and budget limits, argument validation and logging of tool calls. Limits, validation and logs keep autonomous loops safe and debuggable.
