0Pricing
AI Agents with LangChain & Autonomous Workflows · บทเรียน

อธิบายองค์ประกอบหลักของ LangChain

เรียนรู้ส่วนประกอบพื้นฐานของ LangChain ได้แก่ LLM พรอมต์ เชน และเอเจนต์ รวมถึงวิธีที่ส่วนประกอบเหล่านี้ทำงานร่วมกัน

อธิบายองค์ประกอบหลักของ LangChain เป็นบทเรียน AI Agents with LangChain & Autonomous Workflows ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน AI Agents with LangChain & Autonomous Workflows และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส AI Agents with LangChain & Autonomous Workflows มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Welcome to LangChain Core!

Now meet LangChain, a framework for building agents. It gives you modular components you snap together like LEGO bricks.

The Brain: Large Language Models (LLMs)

The agent's brain is the LLM — a model trained on vast text to understand and generate language. LangChain makes it easy to plug into GPT or open-source models.

LLM in Action: A Simple Call

Here's a basic LLM call in LangChain, using a fake model so it runs without any API key.

from langchain_core.llms import FakeListLLM

# Our 'brain' that gives predefined answers
llm = FakeListLLM(responses=[
    "The capital of France is Paris.",
    "Hello! How can I help you today?"
])

# Ask the LLM a question
response = llm.invoke("What is the capital of France?")
print(response)

Guiding the Brain: Prompts

An LLM needs instructions, and those are your prompts — the input text you feed it. Good prompts are crucial for getting the output you want.

Dynamic Prompts: Prompt Templates

For input that changes, use a prompt template: a reusable blueprint with placeholders you fill in at runtime.

from langchain_core.prompts import PromptTemplate

# Define a template with a placeholder '{topic}'
qa_template = """
Answer the following question about {topic}:

Question: {question}
"""

# Create a PromptTemplate object
prompt = PromptTemplate.from_template(qa_template)

# Format the prompt with specific values
formatted_prompt = prompt.format(
    topic="Python programming", 
    question="What is a variable?"
)
print(formatted_prompt)

Connecting Steps: Chains

Most agent tasks take several steps. A chain is a predefined sequence that wires LLMs, prompts, and utilities together, passing each output into the next step.

Building a Simple Chain

Here's a simple chain: a prompt template piped into an LLM using LangChain's Runnable interface. The prompt's output feeds straight into the model.

from langchain_core.llms import FakeListLLM
from langchain_core.prompts import PromptTemplate

# 1. Our 'brain'
llm = FakeListLLM(responses=["A variable is a named storage location."])

# 2. Our prompt template
qa_template = """
Explain {concept} in simple terms.
"""
prompt = PromptTemplate.from_template(qa_template)

# 3. Combine them into a chain using '|' operator
# The prompt output goes into the LLM as input
chain = prompt | llm

# Invoke the chain with the input for the template
response = chain.invoke({"concept": "variable"})
print(response)

The Orchestrator: Agents

Chains run fixed steps; agents are dynamic. An agent decides which action to take, runs it, observes the result, and repeats until the goal is met.

How Agents Use Components

Agents tie it all together: LLMs for reasoning, prompts to guide thinking, chains for multi-step work, and tools to act on the real world.

Putting it All Together

Picture a smart assistant: a prompt sets the task, the LLM reasons, a chain processes input, and the agent picks a weather tool — then the LLM formats the answer.

Quick Check: Core Components

Which LangChain component is primarily responsible for dynamic decision-making and tool selection in an AI application?

Recap & Next Steps

Recap: the four LangChain building blocks — LLMs (the brain), prompts (instructions), chains (sequences), and agents (dynamic deciders). Next: build one.

คำถามที่พบบ่อย

บทเรียน “อธิบายองค์ประกอบหลักของ LangChain” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “อธิบายองค์ประกอบหลักของ LangChain” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส AI Agents with LangChain & Autonomous Workflows ให้อัปเกรดเป็น CoddyKit PRO คอร์ส AI Agents with LangChain & Autonomous Workflows มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “อธิบายองค์ประกอบหลักของ LangChain”

เรียนรู้ส่วนประกอบพื้นฐานของ LangChain ได้แก่ LLM พรอมต์ เชน และเอเจนต์ รวมถึงวิธีที่ส่วนประกอบเหล่านี้ทำงานร่วมกัน คุณปฏิบัติ AI Agents with LangChain & Autonomous Workflows ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน AI Agents with LangChain & Autonomous Workflows หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน AI Agents with LangChain & Autonomous Workflows บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน

บทเรียน “อธิบายองค์ประกอบหลักของ LangChain” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน AI Agents with LangChain & Autonomous Workflows นี้ได้ไหม

ได้ บทเรียน AI Agents with LangChain & Autonomous Workflows ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. ทำความเข้าใจเอเจนต์ปัญญาประดิษฐ์และ LLM
  2. อธิบายองค์ประกอบหลักของ LangChain
  3. การสร้างเอเจนต์อย่างง่ายตัวแรก
  4. เพิ่มความจำและสถานะการสนทนาให้เอเจนต์
← กลับไปที่ AI Agents with LangChain & Autonomous Workflows