메인 콘텐츠로 건너뛰기
Alpha Notice: These docs cover the v1-alpha release. Content is incomplete and subject to change.For the latest stable version, see the current LangGraph Python or LangGraph JavaScript docs.
이 가이드에서는 LangGraph 애플리케이션을 로컬에서 실행하는 방법을 보여줍니다.

사전 요구 사항

시작하기 전에 다음을 준비해야 합니다:
  • LangSmith API 키 - 무료로 가입할 수 있습니다

1. LangGraph CLI 설치

# Python >= 3.11이 필요합니다.
pip install -U "langgraph-cli[inmem]"

2. LangGraph 앱 생성 🌱

new-langgraph-project-python 템플릿에서 새 앱을 생성합니다. 이 템플릿은 자신의 로직으로 확장할 수 있는 단일 노드 애플리케이션을 보여줍니다.
langgraph new path/to/your/app --template new-langgraph-project-python
추가 템플릿 템플릿을 지정하지 않고 langgraph new를 사용하면 사용 가능한 템플릿 목록에서 선택할 수 있는 대화형 메뉴가 표시됩니다.

3. 종속성 설치

새로운 LangGraph 앱의 루트에서 edit 모드로 종속성을 설치하여 서버가 로컬 변경 사항을 사용하도록 합니다:
cd path/to/your/app
pip install -e .

4. .env 파일 생성

새로운 LangGraph 앱의 루트에 .env.example 파일이 있습니다. 루트에 .env 파일을 생성하고 .env.example 파일의 내용을 복사한 다음 필요한 API 키를 입력합니다:
LANGSMITH_API_KEY=lsv2...

5. LangGraph Server 실행 🚀

LangGraph API 서버를 로컬에서 시작합니다:
langgraph dev
샘플 출력:
>    Ready!
>
>    - API: [http://localhost:2024](http://localhost:2024/)
>
>    - Docs: http://localhost:2024/docs
>
>    - LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
langgraph dev 명령은 인메모리 모드로 LangGraph Server를 시작합니다. 이 모드는 개발 및 테스트 목적에 적합합니다. 프로덕션 사용을 위해서는 영구 스토리지 백엔드에 액세스할 수 있는 LangGraph Server를 배포하세요. 자세한 내용은 배포 옵션을 참조하세요.

6. LangGraph Studio에서 애플리케이션 테스트

LangGraph Studio는 LangGraph API 서버에 연결하여 애플리케이션을 시각화하고 상호 작용하며 로컬에서 디버그할 수 있는 전용 UI입니다. langgraph dev 명령의 출력에 제공된 URL을 방문하여 LangGraph Studio에서 그래프를 테스트하세요:
>    - LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
사용자 지정 호스트/포트에서 실행되는 LangGraph Server의 경우 baseURL 매개변수를 업데이트하세요.
Safari는 localhost 서버에 연결할 때 제한이 있으므로 명령에 --tunnel 플래그를 사용하여 보안 터널을 생성하세요:
langgraph dev --tunnel

7. API 테스트

  • Python SDK (async)
  • Python SDK (sync)
  • Rest API
  1. LangGraph Python SDK를 설치합니다:
pip install langgraph-sdk
  1. 어시스턴트에 메시지를 보냅니다 (스레드 없는 실행):
from langgraph_sdk import get_client
import asyncio

client = get_client(url="http://localhost:2024")

async def main():
    async for chunk in client.runs.stream(
        None,  # Threadless run
        "agent", # Name of assistant. Defined in langgraph.json.
        input={
        "messages": [{
            "role": "human",
            "content": "What is LangGraph?",
            }],
        },
    ):
        print(f"Receiving new event of type: {chunk.event}...")
        print(chunk.data)
        print("\n\n")

asyncio.run(main())

다음 단계

이제 로컬에서 실행되는 LangGraph 앱이 있으므로 배포 및 고급 기능을 탐색하여 여정을 더욱 발전시키세요:
I