0Pricing
AI Agents with LangChain & Autonomous Workflows · 강의

추적과 모니터링을 위한 LangSmith

LangSmith를 활용해 에이전트의 사고 과정, 도구 사용, 전체 실행 흐름을 파악합니다.

추적과 모니터링을 위한 LangSmith은(는) CoddyKit의 무료 AI Agents with LangChain & Autonomous Workflows 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 AI Agents with LangChain & Autonomous Workflows 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. AI Agents with LangChain & Autonomous Workflows 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Seeing Inside Your Agent

When you build an AI agent, it often feels like a black box. You provide an input, and it gives an output, but what happens in between?

  • Did it understand your prompt correctly?
  • Which tools did it decide to use?
  • Why did it choose that particular action?

Understanding these internal workings is crucial for debugging and improving your agents.

Introducing LangSmith

LangSmith is a developer platform by LangChain, designed specifically for building, debugging, and evaluating Large Language Model (LLM) applications.

It provides the visibility you need to understand your agent's behavior, identify issues, and ensure it performs as expected.

Core Concepts: Traces & Runs

In LangSmith, two key concepts are Runs and Traces:

  • A Run represents a single execution of a component, like an LLM call, a tool invocation, or a chain step.
  • A Trace is a collection of related runs that together form a complete execution of your agent or application, showing the full sequence of events.

Imagine a trace as a detailed log of your agent's entire thought process and actions.

Setting Up LangSmith

To use LangSmith, you need to set a few environment variables:

  • LANGCHAIN_TRACING_V2=true: Enables LangSmith tracing.
  • LANGCHAIN_API_KEY: Your unique API key for authentication.
  • LANGCHAIN_PROJECT: A name for your project to group related traces.

You can get your API key from the LangSmith website after signing up.

Enabling Tracing in Code

Let's see how to enable tracing for a simple LangChain application. First, ensure you have your API key and project name set up.

import os
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

# Set these environment variables before running
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_API_KEY"] = "YOUR_LANGSMITH_API_KEY"
os.environ["LANGCHAIN_PROJECT"] = "MyFirstLangSmithProject"

# Replace with your actual OpenAI API key
os.environ["OPENAI_API_KEY"] = "YOUR_OPENAI_API_KEY"

# Create a simple LLM chain
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant."),
    ("user", "{question}")
])
chain = prompt | llm

# Invoke the chain
response = chain.invoke({"question": "What is the capital of France?"})
print(response.content)

Viewing Your First Trace

After running the previous code, a trace will be sent to your LangSmith project. Navigate to the LangSmith UI (app.langsmith.com) and select your project.

You'll see a visual representation of the 'chain' execution, including:

  • The input to the prompt.
  • The LLM call itself.
  • The final output from the LLM.

Each step is a 'Run' within the 'Trace'.

Understanding Agent Thought Process

For more complex agents, LangSmith shines by showing the agent's thought process. You can see the sequence of:

  • Thought: The agent's reasoning.
  • Action: The tool it decided to use.
  • Action Input: The arguments passed to the tool.
  • Observation: The result returned by the tool.

This detailed breakdown helps you understand why an agent made certain decisions.

Monitoring Tool Usage

Agents often rely on various tools (e.g., search engines, calculators, custom APIs). LangSmith traces clearly show:

  • Which specific tools were called.
  • The exact inputs provided to each tool.
  • The outputs received from the tools.

This is invaluable for verifying that your agent is using tools correctly and for debugging when a tool returns an unexpected result.

Debugging with LangSmith Traces

Traces are your best friend for debugging. If your agent behaves unexpectedly:

  • Identify the exact step: Pinpoint where the incorrect logic or error occurred.
  • Inspect inputs/outputs: Check if the prompt received the expected input or if the tool returned the right output.
  • Review agent thoughts: Understand if the agent's reasoning led to a bad decision.

This visibility dramatically reduces debugging time compared to traditional print statements.

Check Your Knowledge

Which of the following is NOT a primary benefit of using LangSmith for AI agents?

Recap: Your Observability Ally

LangSmith is an essential tool for anyone building AI agents with LangChain. It transforms the black box of agent execution into a transparent, inspectable process.

By providing detailed traces of runs, agent thoughts, and tool usage, LangSmith empowers you to debug faster, understand your agents better, and build more robust and reliable AI applications.

자주 묻는 질문

“추적과 모니터링을 위한 LangSmith” 강의는 무료인가요?

네 — “추적과 모니터링을 위한 LangSmith” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 AI Agents with LangChain & Autonomous Workflows 강의 전체를 잠금 해제할 수 있습니다. AI Agents with LangChain & Autonomous Workflows 강의에는 총 4개의 강의가 포함되어 있습니다.

“추적과 모니터링을 위한 LangSmith”에서 뭘 배우나요?

LangSmith를 활용해 에이전트의 사고 과정, 도구 사용, 전체 실행 흐름을 파악합니다. 브라우저에서 직접 실행하는 실습 코드로 AI Agents with LangChain & Autonomous Workflows을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

AI Agents with LangChain & Autonomous Workflows을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 AI Agents with LangChain & Autonomous Workflows은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“추적과 모니터링을 위한 LangSmith” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 AI Agents with LangChain & Autonomous Workflows 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 AI Agents with LangChain & Autonomous Workflows 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 추적과 모니터링을 위한 LangSmith
  2. 에이전트 사고 과정 디버깅
  3. 에이전트 성능 평가
  4. 토큰 사용량 및 비용 모니터링
← AI Agents with LangChain & Autonomous Workflows(으)로 돌아가기