# langchain-for-beginners **Repository Path**: SpikeXue_admin/langchain-for-beginners ## Basic Information - **Project Name**: langchain-for-beginners - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-09 - **Last Updated**: 2025-12-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LangChain for Beginners - A Course LangChain Cover Image A course teaching everything you need to know to start building AI Agents with LangChain [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/microsoft/langchain-for-beginners/blob/main/LICENSE) [![GitHub contributors](https://img.shields.io/github/contributors/microsoft/langchain-for-beginners.svg)](https://github.com/microsoft/langchain-for-beginners/graphs/contributors/) [![GitHub issues](https://img.shields.io/github/issues/microsoft/langchain-for-beginners.svg)](https://github.com/microsoft/langchain-for-beginners/issues/) [![GitHub pull-requests](https://img.shields.io/github/issues-pr/microsoft/langchain-for-beginners.svg)](https://github.com/microsoft/langchain-for-beginners/pulls/) [![GitHub watchers](https://img.shields.io/github/watchers/microsoft/langchain-for-beginners.svg?style=social&label=Watch)](https://github.com/microsoft/langchain-for-beginners/) [![GitHub forks](https://img.shields.io/github/forks/microsoft/langchain-for-beginners.svg?style=social&label=Fork)](https://github.com/microsoft/langchain-for-beginners/) [![GitHub stars](https://img.shields.io/github/stars/microsoft/langchain-for-beginners.svg?style=social&label=Star)](https://github.com/microsoft/langchain-for-beginners/) ## 🦜🔗 Welcome Welcome to **LangChain for Beginners**! This course will cover the fundamentals of building with LangChain and Python. It contains [**9 chapters**](#-table-of-contents) that each focus on a specific concept. To **get started** right away you can navigate to the [course-setup](/00-course-setup/) chapter, but you're encouraged to read the overview below first. ### What You'll Learn and Build This course takes you from zero to building robust AI applications: - **Conversational AI** - Build context-aware chatbots with streaming responses and customizable behavior - **Semantic Search** - Create search systems that understand meaning, not just keywords - **Function Calling & Tools** - Give AI the ability to use tools and extract structured data - **Autonomous Agents** - Build agents that reason, make decisions, and choose tools autonomously - **MCP Integration** - Connect AI to external services using the Model Context Protocol standard - **Agentic RAG** - Build intelligent Q&A systems where agents decide when to search your knowledge base **By the end**, you'll have a solid understanding of LangChain and understand how to build real AI applications you can deploy! > **Teaching Approach:** We use an agent-first progression. You'll learn about tools, then agents, then combine them with document retrieval to build agentic RAG systems. This mirrors how modern production AI systems are built. Don't forget to [star (🌟)](https://github.com/microsoft/langchain-for-beginners/stargazers) and [fork this repo](https://github.com/microsoft/langchain-for-beginners/fork) to run the code. --- ## 📚 Table of Contents This course contains **9 chapters** (setup + 8 chapters), each building on the previous to teach you LangChain from the ground up. Each chapter includes conceptual explanations, working code examples, and hands-on challenges. | # | Chapter | Description | Key Concepts | |---|---------|-------------|--------------| | 0 | [Course Setup](./00-course-setup/README.md) | Set up your development environment (local or cloud-based) | Python, Azure AI Foundry, Codespaces, environment variables | | 1 | [Introduction to LangChain](./01-introduction/README.md) | Understanding the framework and core concepts | LangChain fundamentals, first LLM call | | 2 | [Chat Models & Basic Interactions](./02-chat-models/README.md) | Chat models, messages, and conversations | Message types, streaming, error handling, temperature | | 3 | [Prompts, Messages, and Structured Outputs](./03-prompts-messages-outputs/README.md) | Working with prompts, message arrays, and type-safe outputs | Messages, templates, structured outputs, Pydantic schemas | | 4 | [Function Calling & Tools](./04-function-calling-tools/README.md) | Extending AI capabilities with function calling and tools | Pydantic schemas, tool binding, type safety | | 5 | [Getting Started with Agents](./05-agents/README.md) | Building autonomous agents that reason and choose tools | ReAct pattern, agent loops, create_agent(), middleware | | 6 | [Model Context Protocol (MCP)](./06-mcp/README.md) | Connect AI to external services using the MCP standard | MCP servers, stdio transports, tool integration, multi-server patterns | | 7 | [Documents, Embeddings & Semantic Search](./07-documents-embeddings-semantic-search/README.md) | Loading documents, creating embeddings, and building semantic search | Document loading, chunking, vector embeddings, similarity search | | 8 | [Building Agentic RAG Systems](./08-agentic-rag-systems/README.md) | Building RAG systems where agents intelligently decide when to search documents | Agentic RAG (agents decide when to search), retrieval tools, intelligent Q&A | Each chapter includes: - 📖 **Conceptual explanations** with real-world analogies - 💻 **Code examples** you can run immediately - 🎯 **Hands-on challenges** to test your understanding - 🔑 **Key takeaways** to reinforce learning We're planning to expand this course over time with additional topics. Stay tuned for updates! --- ## 📋 Prerequisites Before starting this course, you should be comfortable with: - **Python fundamentals** - Variables, functions, objects, async/await, pip for package installation - **Basic Generative AI concepts** - Basic understanding of LLMs, prompts, tokens which are covered in our [GenAI for Beginners](https://github.com/microsoft/generative-ai-for-beginners) course ### Required Tools - [Python 3.10 or later](https://python.org/) - Github Account - Code editor ([VS Code recommended](https://code.visualstudio.com/)) (if running the course locally.) ## 👫 Meet Other Learners, Get Your Questions Answered If you get stuck or have any questions about building AI Agents, join our dedicated LangChain Discord Channel in the [Microsoft Foundry Community Discord](https://aka.ms/langchain-foundry/discord). ## 🙏 Want to help? Do you have suggestions or found spelling or code errors? [Raise an issue](https://github.com/microsoft/langchain-for-beginners/issues) or [Create a pull request](https://github.com/microsoft/langchain-for-beginners/pull). ## 📖 Course Resources and Additional Samples - **[Glossary](./GLOSSARY.md)** - Comprehensive definitions of all terms used throughout the course - **[LangChain Documentation](https://docs.langchain.com/oss/python/langchain/overview)** - Official LangChain docs for deeper dives - **[LangChain Sales Analysis Agent Sample](https://github.com/Azure-Samples/langchain-agent-python)** - Learn how to build a sales analysis agent with LangChain, MCP and PostGreSQL - **[Email Agent Sample](https://github.com/microsoft/local-email-agent/)** - Learn how to build an email agent with LangChain and MCP that can be run locally with phi-4 or deployed to the cloud. --- ## Additional Resources ### LangChain [![LangChain.js for Beginners](https://img.shields.io/badge/LangChain.js%20for%20Beginners-22C55E?style=for-the-badge&labelColor=E5E7EB&color=0553D6)](https://aka.ms/langchainjs-for-beginners?WT.mc_id=m365-94501-dwahlin) [![LangChain4j for Beginners](https://img.shields.io/badge/LangChain4j%20for%20Beginners-22C55E?style=for-the-badge&&labelColor=E5E7EB&color=0553D6)](https://aka.ms/langchain4j-for-beginners) --- ### Azure / Edge / MCP / Agents [![AZD for Beginners](https://img.shields.io/badge/AZD%20for%20Beginners-0078D4?style=for-the-badge&labelColor=E5E7EB&color=0078D4)](https://github.com/microsoft/AZD-for-beginners?WT.mc_id=academic-105485-koreyst) [![Edge AI for Beginners](https://img.shields.io/badge/Edge%20AI%20for%20Beginners-00B8E4?style=for-the-badge&labelColor=E5E7EB&color=00B8E4)](https://github.com/microsoft/edgeai-for-beginners?WT.mc_id=academic-105485-koreyst) [![MCP for Beginners](https://img.shields.io/badge/MCP%20for%20Beginners-009688?style=for-the-badge&labelColor=E5E7EB&color=009688)](https://github.com/microsoft/mcp-for-beginners?WT.mc_id=academic-105485-koreyst) [![AI Agents for Beginners](https://img.shields.io/badge/AI%20Agents%20for%20Beginners-00C49A?style=for-the-badge&labelColor=E5E7EB&color=00C49A)](https://github.com/microsoft/ai-agents-for-beginners?WT.mc_id=academic-105485-koreyst) --- ### Generative AI Series [![Generative AI for Beginners](https://img.shields.io/badge/Generative%20AI%20for%20Beginners-8B5CF6?style=for-the-badge&labelColor=E5E7EB&color=8B5CF6)](https://github.com/microsoft/generative-ai-for-beginners?WT.mc_id=academic-105485-koreyst) [![Generative AI (.NET)](https://img.shields.io/badge/Generative%20AI%20(.NET)-9333EA?style=for-the-badge&labelColor=E5E7EB&color=9333EA)](https://github.com/microsoft/Generative-AI-for-beginners-dotnet?WT.mc_id=academic-105485-koreyst) [![Generative AI (Java)](https://img.shields.io/badge/Generative%20AI%20(Java)-C084FC?style=for-the-badge&labelColor=E5E7EB&color=C084FC)](https://github.com/microsoft/generative-ai-for-beginners-java?WT.mc_id=academic-105485-koreyst) [![Generative AI (JavaScript)](https://img.shields.io/badge/Generative%20AI%20(JavaScript)-E879F9?style=for-the-badge&labelColor=E5E7EB&color=E879F9)](https://github.com/microsoft/generative-ai-with-javascript?WT.mc_id=academic-105485-koreyst) --- ### Core Learning [![ML for Beginners](https://img.shields.io/badge/ML%20for%20Beginners-22C55E?style=for-the-badge&labelColor=E5E7EB&color=22C55E)](https://aka.ms/ml-beginners?WT.mc_id=academic-105485-koreyst) [![Data Science for Beginners](https://img.shields.io/badge/Data%20Science%20for%20Beginners-84CC16?style=for-the-badge&labelColor=E5E7EB&color=84CC16)](https://aka.ms/datascience-beginners?WT.mc_id=academic-105485-koreyst) [![AI for Beginners](https://img.shields.io/badge/AI%20for%20Beginners-A3E635?style=for-the-badge&labelColor=E5E7EB&color=A3E635)](https://aka.ms/ai-beginners?WT.mc_id=academic-105485-koreyst) [![Cybersecurity for Beginners](https://img.shields.io/badge/Cybersecurity%20for%20Beginners-F97316?style=for-the-badge&labelColor=E5E7EB&color=F97316)](https://github.com/microsoft/Security-101?WT.mc_id=academic-96948-sayoung) [![Web Dev for Beginners](https://img.shields.io/badge/Web%20Dev%20for%20Beginners-EC4899?style=for-the-badge&labelColor=E5E7EB&color=EC4899)](https://aka.ms/webdev-beginners?WT.mc_id=academic-105485-koreyst) [![IoT for Beginners](https://img.shields.io/badge/IoT%20for%20Beginners-14B8A6?style=for-the-badge&labelColor=E5E7EB&color=14B8A6)](https://aka.ms/iot-beginners?WT.mc_id=academic-105485-koreyst) [![XR Development for Beginners](https://img.shields.io/badge/XR%20Development%20for%20Beginners-38BDF8?style=for-the-badge&labelColor=E5E7EB&color=38BDF8)](https://github.com/microsoft/xr-development-for-beginners?WT.mc_id=academic-105485-koreyst) --- ### Copilot Series [![Copilot for AI Paired Programming](https://img.shields.io/badge/Copilot%20for%20AI%20Paired%20Programming-FACC15?style=for-the-badge&labelColor=E5E7EB&color=FACC15)](https://aka.ms/GitHubCopilotAI?WT.mc_id=academic-105485-koreyst) [![Copilot for C#/.NET](https://img.shields.io/badge/Copilot%20for%20C%23/.NET-FBBF24?style=for-the-badge&labelColor=E5E7EB&color=FBBF24)](https://github.com/microsoft/mastering-github-copilot-for-dotnet-csharp-developers?WT.mc_id=academic-105485-koreyst) [![Copilot Adventure](https://img.shields.io/badge/Copilot%20Adventure-FDE68A?style=for-the-badge&labelColor=E5E7EB&color=FDE68A)](https://github.com/microsoft/CopilotAdventures?WT.mc_id=academic-105485-koreyst) --- ## Getting Help If you get stuck or have any questions about building AI apps, join: [![Microsoft Foundry Discord](https://img.shields.io/badge/Discord-Azure_AI_Foundry_Community_Discord-blue?style=for-the-badge&logo=discord&color=5865f2&logoColor=fff)](https://aka.ms/foundry/discord) If you have product feedback or errors while building visit: [![Microsoft Foundry Developer Forum](https://img.shields.io/badge/GitHub-Azure_AI_Foundry_Developer_Forum-blue?style=for-the-badge&logo=github&color=000000&logoColor=fff)](https://aka.ms/foundry/forum) --- ## Contributing This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. ## Trademarks This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos is subject to those third-parties' policies.