pyproject.toml을 사용하여 패키지 의존성을 정의하고 배포용 애플리케이션을 설정하는 기본 단계를 설명합니다.
이 예제는 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.
requirements.txt: 의존성 관리를 위해 LangSmith에서requirements.txt를 사용하는 방법은 이 가이드를 참조하세요.- 모노레포: 모노레포 내부에 있는 그래프를 배포하려면 이 저장소에서 예제를 확인하세요.
의존성 지정
의존성은 선택적으로pyproject.toml, setup.py 또는 requirements.txt 파일 중 하나에 지정할 수 있습니다. 이러한 파일을 생성하지 않은 경우, 나중에 구성 파일에서 의존성을 지정할 수 있습니다.
아래 의존성은 이미지에 포함되며, 호환 가능한 버전 범위 내에서 코드에서 사용할 수 있습니다:
pyproject.toml 파일 예제:
환경 변수 지정
환경 변수는 선택적으로 파일(예:.env)에 지정할 수 있습니다. 배포에 대한 추가 변수를 구성하려면 환경 변수 참조를 참조하세요.
.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: addallow-prereleases = trueto your[tool.uv]section. - With
requirements.txtorsetup.py: you must explicitly specify every prerelease dependency, including transitive ones. For example, if you declarea==0.0.1a1andadepends onb==0.0.1a1, then you must also explicitly includeb==0.0.1a1in your dependencies.
그래프 정의
그래프를 구현합니다. 그래프는 단일 파일 또는 여러 파일로 정의할 수 있습니다. 애플리케이션에 포함될 각 CompiledStateGraph의 변수 이름을 기록해 두세요. 이 변수 이름은 나중에 구성 파일을 생성할 때 사용됩니다. 다른 모듈에서 가져오는 방법을 보여주는agent.py 파일 예제입니다(모듈 코드는 여기에 표시되지 않으며, 구현을 보려면 이 저장소를 참조하세요):
구성 파일 생성
langgraph.json이라는 구성 파일을 생성합니다. 구성 파일의 JSON 객체에 있는 각 키에 대한 자세한 설명은 구성 파일 참조를 참조하세요.
langgraph.json 파일 예제:
CompiledGraph의 변수 이름이 최상위 graphs 키에 있는 각 하위 키 값의 끝에 나타납니다(즉, :<variable_name>).
구성 파일 위치
구성 파일은 컴파일된 그래프와 관련 의존성을 포함하는 Python 파일과 같은 수준 또는 상위 디렉터리에 배치되어야 합니다.
다음 단계
프로젝트를 설정하고 GitHub 저장소에 배치한 후에는 앱을 배포할 차례입니다.Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.