Skip to main content
LangSmith에 배포하거나 자체 호스팅하려면 애플리케이션이 구성 파일로 구성되어야 합니다. 이 가이드에서는 pyproject.toml을 사용하여 패키지 의존성을 정의하고 배포용 애플리케이션을 설정하는 기본 단계를 설명합니다. 이 예제는 LangGraph 프레임워크를 사용하는 이 저장소를 기반으로 합니다. 최종 저장소 구조는 다음과 같습니다:
my-app/
├── my_agent # 모든 프로젝트 코드가 여기에 있습니다
   ├── utils # 그래프를 위한 유틸리티
   ├── __init__.py
   ├── tools.py # 그래프를 위한 도구
   ├── nodes.py # 그래프를 위한 노드 함수
   └── state.py # 그래프의 상태 정의
│   ├── __init__.py
│   └── agent.py # 그래프를 구성하는 코드
├── .env # 환경 변수
├── langgraph.json  # LangGraph 구성 파일
└── pyproject.toml # 프로젝트 의존성
LangSmith Deployment supports deploying a LangGraph graph. However, the implementation of a node of a graph can contain arbitrary Python code. This means any framework can be implemented within a node and deployed on LangSmith Deployment. This lets you keep your core application logic outside LangGraph while still using LangSmith for deployment, scaling, and observability.
다음 방법으로도 설정할 수 있습니다:
  • requirements.txt: 의존성 관리를 위해 LangSmith에서 requirements.txt를 사용하는 방법은 이 가이드를 참조하세요.
  • 모노레포: 모노레포 내부에 있는 그래프를 배포하려면 이 저장소에서 예제를 확인하세요.
각 단계 후에는 코드를 구성하는 방법을 보여주는 예제 파일 디렉터리가 제공됩니다.

의존성 지정

의존성은 선택적으로 pyproject.toml, setup.py 또는 requirements.txt 파일 중 하나에 지정할 수 있습니다. 이러한 파일을 생성하지 않은 경우, 나중에 구성 파일에서 의존성을 지정할 수 있습니다. 아래 의존성은 이미지에 포함되며, 호환 가능한 버전 범위 내에서 코드에서 사용할 수 있습니다:
langgraph>=0.6.0
langgraph-sdk>=0.1.66
langgraph-checkpoint>=2.0.23
langchain-core>=0.2.38
langsmith>=0.1.63
orjson>=3.9.7,<3.10.17
httpx>=0.25.0
tenacity>=8.0.0
uvicorn>=0.26.0
sse-starlette>=2.1.0,<2.2.0
uvloop>=0.18.0
httptools>=0.5.0
jsonschema-rs>=0.20.0
structlog>=24.1.0
cloudpickle>=3.0.0
pyproject.toml 파일 예제:
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "my-agent"
version = "0.0.1"
description = "An excellent agent build for LangSmith."
authors = [
    {name = "Polly the parrot", email = "[email protected]"}
]
license = {text = "MIT"}
readme = "README.md"
requires-python = ">=3.9"
dependencies = [
    "langgraph>=0.6.0",
    "langchain-fireworks>=0.1.3"
]

[tool.hatch.build.targets.wheel]
packages = ["my_agent"]
예제 파일 디렉터리:
my-app/
└── pyproject.toml   # 그래프에 필요한 Python 패키지

환경 변수 지정

환경 변수는 선택적으로 파일(예: .env)에 지정할 수 있습니다. 배포에 대한 추가 변수를 구성하려면 환경 변수 참조를 참조하세요. .env 파일 예제:
MY_ENV_VAR_1=foo
MY_ENV_VAR_2=bar
FIREWORKS_API_KEY=key
예제 파일 디렉터리:
my-app/
├── .env # 환경 변수를 담은 파일
└── pyproject.toml
By default, LangSmith follows the uv/pip behavior of not installing prerelease versions unless explicitly allowed. If want to use prereleases, you have the following options:
  • With pyproject.toml: add allow-prereleases = true to your [tool.uv] section.
  • With requirements.txt or setup.py: you must explicitly specify every prerelease dependency, including transitive ones. For example, if you declare a==0.0.1a1 and a depends on b==0.0.1a1, then you must also explicitly include b==0.0.1a1 in your dependencies.

그래프 정의

그래프를 구현합니다. 그래프는 단일 파일 또는 여러 파일로 정의할 수 있습니다. 애플리케이션에 포함될 각 CompiledStateGraph의 변수 이름을 기록해 두세요. 이 변수 이름은 나중에 구성 파일을 생성할 때 사용됩니다. 다른 모듈에서 가져오는 방법을 보여주는 agent.py 파일 예제입니다(모듈 코드는 여기에 표시되지 않으며, 구현을 보려면 이 저장소를 참조하세요):
# my_agent/agent.py
from typing import Literal
from typing_extensions import TypedDict

from langgraph.graph import StateGraph, END, START
from my_agent.utils.nodes import call_model, should_continue, tool_node # 노드 가져오기
from my_agent.utils.state import AgentState # 상태 가져오기

# 런타임 컨텍스트 정의
class GraphContext(TypedDict):
    model_name: Literal["anthropic", "openai"]

workflow = StateGraph(AgentState, context_schema=GraphContext)
workflow.add_node("agent", call_model)
workflow.add_node("action", tool_node)
workflow.add_edge(START, "agent")
workflow.add_conditional_edges(
    "agent",
    should_continue,
    {
        "continue": "action",
        "end": END,
    },
)
workflow.add_edge("action", "agent")

graph = workflow.compile()
예제 파일 디렉터리:
my-app/
├── my_agent # 모든 프로젝트 코드가 여기에 있습니다
   ├── utils # 그래프를 위한 유틸리티
   ├── __init__.py
   ├── tools.py # 그래프를 위한 도구
   ├── nodes.py # 그래프를 위한 노드 함수
   └── state.py # 그래프의 상태 정의
│   ├── __init__.py
│   └── agent.py # 그래프를 구성하는 코드
├── .env
└── pyproject.toml

구성 파일 생성

langgraph.json이라는 구성 파일을 생성합니다. 구성 파일의 JSON 객체에 있는 각 키에 대한 자세한 설명은 구성 파일 참조를 참조하세요. langgraph.json 파일 예제:
{
  "dependencies": ["."],
  "graphs": {
    "agent": "./my_agent/agent.py:graph"
  },
  "env": ".env"
}
CompiledGraph의 변수 이름이 최상위 graphs 키에 있는 각 하위 키 값의 끝에 나타납니다(즉, :<variable_name>).
구성 파일 위치 구성 파일은 컴파일된 그래프와 관련 의존성을 포함하는 Python 파일과 같은 수준 또는 상위 디렉터리에 배치되어야 합니다.
예제 파일 디렉터리:
my-app/
├── my_agent # 모든 프로젝트 코드가 여기에 있습니다
   ├── utils # 그래프를 위한 유틸리티
   ├── __init__.py
   ├── tools.py # 그래프를 위한 도구
   ├── nodes.py # 그래프를 위한 노드 함수
   └── state.py # 그래프의 상태 정의
│   ├── __init__.py
│   └── agent.py # 그래프를 구성하는 코드
├── .env # 환경 변수
├── langgraph.json  # LangGraph 구성 파일
└── pyproject.toml # 프로젝트 의존성

다음 단계

프로젝트를 설정하고 GitHub 저장소에 배치한 후에는 앱을 배포할 차례입니다.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I