Skip to main content
애플리케이션을 LangSmith에 배포하거나 자체 호스팅하려면 구성 파일로 구성되어야 합니다. 이 가이드에서는 프로젝트 의존성을 지정하기 위해 requirements.txt를 사용하여 배포용 애플리케이션을 설정하는 기본 단계를 설명합니다. 이 예제는 LangGraph 프레임워크를 사용하는 이 저장소를 기반으로 합니다. 최종 저장소 구조는 다음과 같습니다:
my-app/
├── my_agent # 모든 프로젝트 코드가 여기에 위치
   ├── utils # 그래프용 유틸리티
   ├── __init__.py
   ├── tools.py # 그래프용 도구
   ├── nodes.py # 그래프용 노드 함수
   └── state.py # 그래프의 상태 정의
   ├── requirements.txt # 패키지 의존성
   ├── __init__.py
   └── agent.py # 그래프 구성 코드
├── .env # 환경 변수
└── langgraph.json # LangGraph 구성 파일
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.
다음 방법으로도 설정할 수 있습니다:
  • pyproject.toml: 의존성 관리를 위해 poetry 사용을 선호하는 경우, LangSmith에서 pyproject.toml을 사용하는 방법에 대한 가이드를 참조하세요.
  • 모노레포: 모노레포 내부에 위치한 그래프를 배포하고자 하는 경우, 이 저장소에서 예제를 확인하세요.
각 단계 후에는 코드를 어떻게 구성할 수 있는지 보여주는 예제 파일 디렉터리가 제공됩니다.

의존성 지정

의존성은 다음 파일 중 하나에서 선택적으로 지정할 수 있습니다: 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
requirements.txt 파일 예제:
langgraph
langchain_anthropic
tavily-python
langchain_community
langchain_openai

파일 디렉터리 예제:
my-app/
├── my_agent # 모든 프로젝트 코드가 여기에 위치
   └── requirements.txt # 패키지 의존성

환경 변수 지정

환경 변수는 파일(예: .env)에서 선택적으로 지정할 수 있습니다. 배포를 위한 추가 변수를 구성하려면 환경 변수 참조를 참조하세요. .env 파일 예제:
MY_ENV_VAR_1=foo
MY_ENV_VAR_2=bar
OPENAI_API_KEY=key
파일 디렉터리 예제:
my-app/
├── my_agent # 모든 프로젝트 코드가 여기에 위치
   └── requirements.txt # 패키지 의존성
└── .env # 환경 변수
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의 변수 이름을 기록해 두세요. 이 변수 이름들은 나중에 LangGraph 구성 파일을 생성할 때 사용됩니다. 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 # 그래프의 상태 정의
   ├── requirements.txt # 패키지 의존성
   ├── __init__.py
   └── agent.py # 그래프 구성 코드
└── .env # 환경 변수

구성 파일 생성

langgraph.json이라는 구성 파일을 생성합니다. 구성 파일의 JSON 객체에 있는 각 키에 대한 자세한 설명은 구성 파일 참조를 참조하세요. langgraph.json 파일 예제:
{
  "dependencies": ["./my_agent"],
  "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 # 그래프의 상태 정의
   ├── requirements.txt # 패키지 의존성
   ├── __init__.py
   └── agent.py # 그래프 구성 코드
├── .env # 환경 변수
└── langgraph.json # LangGraph 구성 파일

다음 단계

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