LangChain is a Python library for building applications powered by large language models. It supplies tools and abstractions for prompt management, LLM chaining, output parsing, and integration with external applications, so developers can focus on application logic rather than model-specific details. section 1.3.3 section 16.2
A standalone LLM can generate text, images, speech, or code, but its training data may omit recent events and real-time facts. LangChain addresses this limitation by letting an agent choose among specialized tools, such as Wolfram Alpha for computation and current information or Wikipedia for factual lookup. section 16.2.1 section 16.3
A practical LangChain agent can grow incrementally:
- Start with an LLM and one tool, such as Wolfram Alpha for numerical or real-time questions. section 16.3
- Add Wikipedia as a fallback for recent facts and historical information. section 16.2.1
- Add prompt-based tools for tasks such as summarization, joke generation, sentiment classification, code generation, or image generation. section 16.3 section 16.3.4
- Let the agent interpret the query and select the appropriate tool without explicitly specifying the workflow. section 16.2.1 section 16.5
Generating a plotting program
A code-generation tool can combine a PromptTemplate, an LLMChain, and an agent executor. Given a request to plot sine and cosine curves from -5 to 5, it produces Python code with NumPy arrays, Matplotlib line styles, a legend, a title, and axis limits.


















