Orchestrating Workflows with LangChain

Core Components of LangChain: Prompts, LLMs, and Output Parsers

Learning Outcome

4

Map a real-world scenario to each component's specific role

3

Recognize how these three components work together in a single pipeline.

2

Identify different types of prompts and output parsers.

1

Roles of Prompts, LLMs, and Output Parsers in a LangChain application.

Recall

LangChain is an open-source LLM framework.

It connects LLMs with data sources, tools, memory, and workflows.

It provides components like loaders, retrievers, chains, and agents.

Prompts provide instructions and context to the LLM.

LLMs process the prompt and generate a response.

 

Output Parsers structure the LLM's response.

The Customer's Order

The Chef

Imagine ordering food at a restaurant. You tell the waiter what you want. The chef prepares the meal. The waiter then serves it neatly on a plate. A LangChain application works the same way:

The Waiter Arranging the Meal on the Plate  

Each component has a specific and essential responsibility.

Think About It

What if one Component is Missing?

The restaurant was just an easy example to help us understand the idea. Now let's break down what Prompts, LLMs, and Output Parsers really are.

If you ask an AI: "List the top five programming languages in JSON format," the AI must understand the request, generate correct information, and return it as valid JSON.

The request may be misunderstood

No response is generated

Output may be unstable by software

Why Are These Three Components Important?

AI must understand the request and return correct information as valid JSON; poor prompts or formatting can make responses unusable by software.

Three components work together to solve this problem every time

 Component 1: Prompts

A Prompt is the instruction or input given to a Large Language Model. It tells the AI what to do, how to answer, what style to use, and what format to follow.

Clearer instructions help produce more useful responses

Prompt Templates: Reusable prompts with dynamically filled placeholders in LangChain.

PromptTemplate.from_template("You are a helpful teacher. Explain the following topic: {topic}") prompt.format(topic="Machine Learning") 

Types of Prompts

1.Open the parent page.

Component 2: Large Language Models  

1.Open the parent page.

The LLM powers the application by understanding prompts, processing information, reasoning, and generating natural language responses.

Examples :

  • Gemini
  • Claude
  • Llama
  • Mistral
  • GPT

How an LLM Works

1.Open the parent page.

Receive the prompt

Analyse the instructions

 Generate the response

Return the generated text

Examples

 llm.invoke("Explain Neural Networks in 50 words.") 

1.Open the parent page.

Neural networks are brain-inspired machine learning models with interconnected neurons arranged in layers that learn patterns for image recognition, speech processing, and NLP.

image recognition

speech processing

natural language processing

LLM Output

 Component 3: Output Parsers  

An Output Parser converts raw LLM responses into structured formats—JSON, lists, tables, or custom objects—for automatic processing by software.

Why we need Output Parser ? 

Types of Output Parsers  

1.Open the parent page.

How These Three Components Work Together (Core Mechanism)  

A team is building an AI application that extracts information from customer feedback forms and sends the results to a database, which expects data in a specific JSON format with fields for customer name, rating, and comment.

Key Point

Nearly every LangChain application follows this same basic flow — a Prompt provides instructions, an LLM generates the response, and an Output Parser formats the result for downstream use. 

Real-Life Examples

Student Information

For student details in JSON, the Prompt defines the task, the LLM generates details, and the Output Parser produces valid JSON.

Weather Assistant

For today’s weather, the LLM generates information, and the Output Parser formats it into a readable table.

Product Recommendation

The Output Parser organises three laptop recommendations, with prices and specifications, into a structured list or table.

Healthcare 

The Output Parser formats diabetes symptoms into a numbered list for easy reading and processing.

Relationship Between the Three Components

 Applications of Prompts, LLMs, and Output Parsers

Used across industries wherever an AI's response must be both intelligent and machine-usable

E-Commerce

Extracting structured product details from a plain-language description for a catalogue system.

Customer Support

 converting a customer's free-text complaint into a structured ticket with category, priority, and summary fields.

HR

 Parsing resumes into structured fields like name, experience, and skills for an applicant tracking system.

Finance

Converting a natural-language transaction summary into structured fields for a reporting system.

Daily Life Applications

       Asking an AI assistant for a recipe and getting it neatly organised into ingredients and steps.

           Asking an AI to extract key details from a long email into a short structured summary.

 A budgeting app converting a plain-language expense description into structured fields (amount, category, date).  

     Asking an AI chatbot for directions and getting a clean, step-by-step numbered list instead of one long paragraph.

An Easy Way to Remember

Think of taking an examination

Like an answer sheet format, the Output Parser structures the result; the Prompt instructs, and the LLM answers.

Summary

5

Structured outputs can include JSON, lists, tables, or custom objects.

4

Output Parsers convert raw AI responses into structured formats.

3

LLMs understand prompts and generate natural language responses.

2

Prompt types include simple, instruction, few-shot, and system prompts.

1

Prompts define instructions and guide the AI’s behavior.

Quiz

Which component converts an LLM response into the required JSON format?

A. Prompt

B. LLM

C. Output Parser

D. Prompt Template

Quiz-Answer

Which component converts an LLM response into the required JSON format?

A. Prompt

B. LLM

C. Output Parser

D. Prompt Template

GenAI - Core Components of LangChain: Prompts, LLMs, and Output Parsers

By Content ITV

GenAI - Core Components of LangChain: Prompts, LLMs, and Output Parsers

  • 152