0Pricing
AI Agents with LangChain & Autonomous Workflows · Pelajaran

Penjelasan Komponen Inti LangChain

Pelajari blok pembangun penting LangChain, termasuk LLM, Prompt, Rantai, dan Agen, serta cara komponen tersebut berinteraksi.

Penjelasan Komponen Inti LangChain adalah pelajaran AI Agents with LangChain & Autonomous Workflows gratis di CoddyKit. Ini adalah pelajaran 2 dari 4. Kamu bisa membaca pelajaran lengkapnya di bawah secara gratis — lalu praktikkan langsung di browser dengan editor kode bawaan dan tutor AI 24/7. Ini adalah bagian dari jalur belajar AI Agents with LangChain & Autonomous Workflows, dan progresmu tersinkronisasi di web dan aplikasi CoddyKit. Kursus AI Agents with LangChain & Autonomous Workflows mencakup 4 pelajaran total.

Bagian dari pelajaran ini belum diterjemahkan dan ditampilkan dalam bahasa Inggris.

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.

Pertanyaan yang Sering Diajukan

Apakah pelajaran “Penjelasan Komponen Inti LangChain” gratis?

Ya — teks lengkap “Penjelasan Komponen Inti LangChain” gratis dibaca di sini di web. Untuk praktiknya secara interaktif (editor kode bawaan dan tutor AI 24/7) dan buka sisa kursus AI Agents with LangChain & Autonomous Workflows, upgrade ke CoddyKit PRO. Kursus AI Agents with LangChain & Autonomous Workflows mencakup 4 pelajaran total.

Apa yang akan aku pelajari di “Penjelasan Komponen Inti LangChain”?

Pelajari blok pembangun penting LangChain, termasuk LLM, Prompt, Rantai, dan Agen, serta cara komponen tersebut berinteraksi. Kamu berlatih AI Agents with LangChain & Autonomous Workflows dengan kode praktik yang langsung kamu jalankan di browser, dan tutor AI 24/7 menjawab pertanyaanmu saat kamu mengerjakan pelajaran ini.

Apakah aku perlu pengalaman untuk memulai AI Agents with LangChain & Autonomous Workflows?

Tidak diperlukan pengalaman sebelumnya. AI Agents with LangChain & Autonomous Workflows di CoddyKit dirancang untuk pemula hingga pelajar tingkat lanjut, jadi kamu bisa memulai di sini atau dari awal dan belajar sesuai kecepatan kamu sendiri. Ini adalah pelajaran 2 dari 4.

Berapa lama pelajaran “Penjelasan Komponen Inti LangChain” memakan waktu?

Sebagian besar pelajaran CoddyKit memakan waktu sekitar 5–10 menit. Setiap pelajaran ringkas dan interaktif, jadi kamu membuat kemajuan stabil dan melanjutkan dari tempat kamu tinggalkan di web dan aplikasi.

Bisakah aku menulis dan menjalankan kode dalam pelajaran AI Agents with LangChain & Autonomous Workflows ini?

Ya. Setiap pelajaran AI Agents with LangChain & Autonomous Workflows menyertakan editor kode bawaan, jadi kamu menulis dan menjalankan kode nyata langsung di browser dan mendapatkan umpan balik AI instan — tidak diperlukan penyiapan lokal.

Semua pelajaran dalam kursus ini

  1. Memahami Agen Kecerdasan Buatan dan LLM
  2. Penjelasan Komponen Inti LangChain
  3. Membangun Agen Sederhana Pertama Anda
  4. Memberi Memori dan Keadaan Percakapan kepada Agen
← Kembali ke AI Agents with LangChain & Autonomous Workflows