炸裂!LangGraph 1.0终于来了!本地化部署LangSmith+LangGraph全流程,支持离线调试与追踪

467 阅读12分钟

炸裂!LangGraph 1.0终于来了!本地化部署LangSmith+LangGraph全流程,支持离线调试与追踪

langgraph 1.0正式版本后,有三种部署的方式, 先说结论:【AI大模型教程】

如果只是部署自己的langgraph服务 使用独立服务器(standalone server)就可以

如果你需要本地的langsmith用来监控,不需要部署管理,使用langsmith方式

如果你还要langsmith的部署管理,使用langsmith with deployment

下面我们分别开始

一   独立服务器(standalone server)

独立服务器:直接部署 LangGraph 服务器,无需控制平面 UI。非常适合将一个或几个代理作为独立服务运行的轻量级设置,并完全控制扩展和集成

1.1 建立LangGraph 应用程序

uv venv --python 3.12

.venv\Scripts\activate

uv pip install -U "langgraph-cli[inmem]"12.安装的时候可以直接 langgraph new ./app --template new-langgraph-project-python如果有选择模板的需求, 可以使用 langgraph new 来到下面的交互界面,可以选择模板 以及 语言
📂 Please specify the path to create the application [.]: ./app
🌟 Please select a template:
1. New LangGraph Project - A simple, minimal chatbot with memory.
2. ReAct Agent - A simple agent that can be flexibly extended to many tools.
3. Memory Agent - A ReAct-style agent with an additional tool to store memories for use across conversational threads.
4. Retrieval Agent - An agent that includes a retrieval-based question-answering system.
5. Data-enrichment Agent - An agent that performs web searches and organizes its findings into a structured format.
Enter the number of your template choice (default is 1): 1
You selected: New LangGraph Project - A simple, minimal chatbot with memory.
Choose language (1 for Python 🐍, 2 for JS/TS 🌐): 1
📥 Attempting to download repository as a ZIP archive...
URL: https://github.com/langchain-ai/new-langgraph-project/archive/refs/heads/main.zip

cd  app

uv pip install -e .建立一个 .env  里面放上 LANGSMITH_API_KEY=lsv2...

1.3 启动 langgraph server

langgraph dev

1.4 让我们测试下

uv pip install langgraph-sdk

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())

1.5 打包成docker image

langgraph build -t langgraph

结束后  docker images 就会看到构建好的镜像

1.6 docker-compose部署

新建一个 docker-compose.yml

volumes:
langgraph-data:
driver: local
services:
langgraph-redis:
image: redis:6
healthcheck:
test: redis-cli ping
interval: 5s
timeout: 1s
retries: 5
langgraph-postgres:
image: postgres:16
ports:
- "5432:5432"
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- langgraph-data:/var/lib/postgresql/data
healthcheck:
test: pg_isready -U postgres
start_period: 10s
timeout: 1s
retries: 5
interval: 5s
langgraph-api:
image: ${IMAGE_NAME}
ports:
- "8123:8000"
depends_on:
langgraph-redis:
condition: service_healthy
langgraph-postgres:
condition: service_healthy
env_file:
- .env
environment:
REDIS_URI: redis://langgraph-redis:6379
LANGSMITH_API_KEY: ${LANGSMITH_API_KEY}
DATABASE_URI: postgres://postgres:postgres@langgraph-postgres:5432/postgres?sslmode=disable

docker compose up 启动

验证下是否启动成功

curl --request GET --url 127.0.0.1:8123/ok 

{"ok":true}

同时langsmith[smith.langchain.com/]平台上也可以看到,项…

二  langsmith 的方式

LangSmith:部署 LangSmith 应用程序的实例,该实例包括 UI 和 API 中的可观测性、跟踪和评估。最适合希望在不部署代理的情况下进行自托管监视和评估的团队

服务描述
LangSmith 前端前端使用 Nginx 来提供 LangSmith UI 并将 API 请求路由到其他服务器。这是应用程序的入口点,也是必须向用户公开的唯一组件。
LangSmith 后端后端是 CRUD API 请求的主要入口点,处理应用程序的大部分业务逻辑。这包括处理来自前端和 SDK 的请求、准备用于摄取的跟踪以及支持中心 API。
LangSmith 队列队列处理传入的跟踪和反馈,以确保它们被异步摄取并持久化到跟踪和反馈数据存储中,处理数据完整性检查并确保成功插入到数据存储中,处理数据库错误或暂时无法连接到数据库等情况下的重试。
LangSmith 平台后端平台后端是另一项关键服务,主要处理身份验证、运行摄取和其他大容量任务。
LangSmith 游乐场Playground 是一项服务,用于处理向各种 LLM API 转发请求以支持 LangSmith Playground 功能。这也可用于连接到您自己的自定义模型服务器。
LangSmith ACE(任意代码执行)后端ACE 后端是一种在安全环境中处理执行任意代码的服务。这用于支持在 LangSmith 中运行自定义代码。

仅用于开发/测试。不要将 Docker Compose 用于生产环境。对于生产部署,请使用

Kubernetes。 我这里演示,为了方便使用docker

2.1 生成一个 Api Key Salt

openssl rand -base64 32

例如  U7MfWaDYNzzgMmvJXKn4Pl41mR5jJVHWrhq6c+6jngE=

docker-compose.yml

services:
langchain-playground:
image: ${_REGISTRY:-docker.io}/langchain/langsmith-playground:${_LANGSMITH_IMAGE_VERSION:-0.11.4}
ports:
- 3001:3001
environment:
- PORT=3001
- LANGCHAIN_ENV=local_docker
- LOG_LEVEL=${LOG_LEVEL:-info}
- GO_ENDPOINT=http://langchain-platform-backend:1986
- SMITH_BACKEND_ENDPOINT=${SMITH_BACKEND_ENDPOINT:-http://langchain-backend:1984}
langchain-frontend:
image: ${_REGISTRY:-docker.io}/langchain/langsmith-frontend:${_LANGSMITH_IMAGE_VERSION:-0.11.4}
environment:
- VITE_BACKEND_AUTH_TYPE=${AUTH_TYPE:-none}
- VITE_BASIC_AUTH_ENABLED=${BASIC_AUTH_ENABLED:-false}
- VITE_OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
- VITE_OAUTH_ISSUER_URL=${OAUTH_ISSUER_URL}
ports:
- 1981:1980
depends_on:
- langchain-backend
- langchain-playground
langchain-ace-backend:
image: ${_REGISTRY:-docker.io}/langchain/langsmith-ace-backend:${_LANGSMITH_IMAGE_VERSION:-0.11.4}
ports:
- 1987:1987
environment:
- PORT=1987
command:
- "deno"
- "run"
- "--unstable-worker-options"
- "--allow-env"
- "--allow-net=0.0.0.0:1987"
- "--node-modules-dir"
- "-R"
- "src/main.ts"
- "-R"
- "src/python_worker.ts"
langchain-backend:
image: ${_REGISTRY:-docker.io}/langchain/langsmith-backend:${_LANGSMITH_IMAGE_VERSION:-0.11.4}
environment:
- PORT=1984
- LANGCHAIN_ENV=local_docker
- LANGSMITH_URL=${LANGSMITH_URL:-http://langchain-frontend:1980}
- GO_ENDPOINT=http://langchain-platform-backend:1986
- SMITH_BACKEND_ENDPOINT=${SMITH_BACKEND_ENDPOINT:-http://langchain-backend:1984}
- LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
- LOG_LEVEL=${LOG_LEVEL:-info}
- AUTH_TYPE=${AUTH_TYPE:-none}
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
- OAUTH_CLIENT_SECRET=${OAUTH_CLIENT_SECRET}
- OAUTH_ISSUER_URL=${OAUTH_ISSUER_URL}
- API_KEY_SALT=${API_KEY_SALT}
- X_SERVICE_AUTH_JWT_SECRET=${API_KEY_SALT}
- POSTGRES_DATABASE_URI=${POSTGRES_DATABASE_URI:-postgres:postgres@langchain-db:5432/postgres}
- REDIS_DATABASE_URI=${REDIS_DATABASE_URI:-redis://langchain-redis:6379}
- CLICKHOUSE_HOST=${CLICKHOUSE_HOST:-langchain-clickhouse}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-password}
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-default}
- CLICKHOUSE_PORT=${CLICKHOUSE_PORT:-8123}
- CLICKHOUSE_TLS=${CLICKHOUSE_TLS:-false}
- FF_ORG_CREATION_DISABLED=${ORG_CREATION_DISABLED:-false}
- FF_TRACE_TIERS_ENABLED=${TTL_ENABLED:-true}
- FF_UPGRADE_TRACE_TIER_ENABLED=${TTL_ENABLED:-true}
- FF_S3_STORAGE_ENABLED=${BLOB_STORAGE_ENABLED:-false}
- S3_BUCKET_NAME=${BLOB_STORAGE_BUCKET_NAME:-langsmith-s3-assets}
- S3_RUN_MANIFEST_BUCKET_NAME=${BLOB_STORAGE_BUCKET_NAME:-langsmith-s3-assets}
- S3_API_URL=${BLOB_STORAGE_API_URL:-https://s3.us-west-2.amazonaws.com}
- S3_ACCESS_KEY=${BLOB_STORAGE_ACCESS_KEY}
- S3_ACCESS_KEY_SECRET=${BLOB_STORAGE_ACCESS_KEY_SECRET}
- FF_CH_SEARCH_ENABLED=${CH_SEARCH_ENABLED:-true}
- BASIC_AUTH_ENABLED=${BASIC_AUTH_ENABLED:-false}
- BASIC_AUTH_JWT_SECRET=${BASIC_AUTH_JWT_SECRET}
- INITIAL_ORG_ADMIN_EMAIL=${INITIAL_ORG_ADMIN_EMAIL}
- INITIAL_ORG_ADMIN_PASSWORD=${INITIAL_ORG_ADMIN_PASSWORD}
- TRACE_TIER_TTL_DURATION_SEC_MAP=${TRACE_TIER_TTL_DURATION_SEC_MAP}
ports:
- 1984:1984
depends_on:
langchain-db:
condition: service_healthy
langchain-redis:
condition: service_healthy
clickhouse-setup:
condition: service_completed_successfully
postgres-setup:
condition: service_completed_successfully
restart: always
langchain-platform-backend:
image: ${_REGISTRY:-docker.io}/langchain/langsmith-go-backend:${_LANGSMITH_IMAGE_VERSION:-0.11.4}
environment:
- PORT=1986
- LANGCHAIN_ENV=local_docker
- LANGSMITH_URL=${LANGSMITH_URL:-http://langchain-frontend:1980}
- SMITH_BACKEND_ENDPOINT=${SMITH_BACKEND_ENDPOINT:-http://langchain-backend:1984}
- LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
- LOG_LEVEL=${LOG_LEVEL:-warning}
- AUTH_TYPE=${AUTH_TYPE:-none}
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
- OAUTH_CLIENT_SECRET=${OAUTH_CLIENT_SECRET}
- OAUTH_ISSUER_URL=${OAUTH_ISSUER_URL}
- API_KEY_SALT=${API_KEY_SALT}
- X_SERVICE_AUTH_JWT_SECRET=${API_KEY_SALT}
- POSTGRES_DATABASE_URI=${POSTGRES_DATABASE_URI:-postgres:postgres@langchain-db:5432/postgres}
- REDIS_DATABASE_URI=${REDIS_DATABASE_URI:-redis://langchain-redis:6379}
- BASIC_AUTH_ENABLED=${BASIC_AUTH_ENABLED:-false}
- BASIC_AUTH_JWT_SECRET=${BASIC_AUTH_JWT_SECRET}
- CLICKHOUSE_HOST=${CLICKHOUSE_HOST:-langchain-clickhouse}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-password}
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-default}
- CLICKHOUSE_PORT=${CLICKHOUSE_PORT:-8123}
- CLICKHOUSE_TLS=${CLICKHOUSE_TLS:-false}
- FF_ORG_CREATION_DISABLED=${ORG_CREATION_DISABLED:-false}
- FF_TRACE_TIERS_ENABLED=${TTL_ENABLED:-true}
- FF_UPGRADE_TRACE_TIER_ENABLED=${TTL_ENABLED:-true}
- FF_S3_STORAGE_ENABLED=${BLOB_STORAGE_ENABLED:-false}
- S3_BUCKET_NAME=${BLOB_STORAGE_BUCKET_NAME:-langsmith-s3-assets}
- S3_RUN_MANIFEST_BUCKET_NAME=${BLOB_STORAGE_BUCKET_NAME:-langsmith-s3-assets}
- S3_API_URL=${BLOB_STORAGE_API_URL:-https://s3.us-west-2.amazonaws.com}
- S3_ACCESS_KEY=${BLOB_STORAGE_ACCESS_KEY}
- S3_ACCESS_KEY_SECRET=${BLOB_STORAGE_ACCESS_KEY_SECRET}
- FF_CH_SEARCH_ENABLED=${CH_SEARCH_ENABLED:-true}
- TRACE_TIER_TTL_DURATION_SEC_MAP=${TRACE_TIER_TTL_DURATION_SEC_MAP}
ports:
- 1986:1986
depends_on:
langchain-db:
condition: service_healthy
langchain-redis:
condition: service_healthy
clickhouse-setup:
condition: service_completed_successfully
postgres-setup:
condition: service_completed_successfully
restart: always
langchain-queue:
image: ${_REGISTRY:-docker.io}/langchain/langsmith-backend:${_LANGSMITH_IMAGE_VERSION:-0.11.4}
environment:
- LANGCHAIN_ENV=local_docker
- GO_ENDPOINT=http://langchain-platform-backend:1986
- SMITH_BACKEND_ENDPOINT=http://langchain-backend:1984
- LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
- LOG_LEVEL=${LOG_LEVEL:-info}
- AUTH_TYPE=${AUTH_TYPE:-none}
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
- OAUTH_ISSUER_URL=${OAUTH_ISSUER_URL}
- API_KEY_SALT=${API_KEY_SALT}
- X_SERVICE_AUTH_JWT_SECRET=${API_KEY_SALT}
- POSTGRES_DATABASE_URI=${POSTGRES_DATABASE_URI:-postgres:postgres@langchain-db:5432/postgres}
- REDIS_DATABASE_URI=${REDIS_DATABASE_URI:-redis://langchain-redis:6379}
- CLICKHOUSE_HOST=${CLICKHOUSE_HOST:-langchain-clickhouse}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-password}
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-default}
- CLICKHOUSE_PORT=${CLICKHOUSE_PORT:-8123}
- CLICKHOUSE_TLS=${CLICKHOUSE_TLS:-false}
- FF_ORG_CREATION_DISABLED=${ORG_CREATION_DISABLED:-false}
- FF_TRACE_TIERS_ENABLED=${TTL_ENABLED:-true}
- FF_UPGRADE_TRACE_TIER_ENABLED=${TTL_ENABLED:-true}
- FF_S3_STORAGE_ENABLED=${BLOB_STORAGE_ENABLED:-false}
- S3_BUCKET_NAME=${BLOB_STORAGE_BUCKET_NAME:-langsmith-s3-assets}
- S3_RUN_MANIFEST_BUCKET_NAME=${BLOB_STORAGE_BUCKET_NAME:-langsmith-s3-assets}
- S3_API_URL=${BLOB_STORAGE_API_URL:-https://s3.us-west-2.amazonaws.com}
- S3_ACCESS_KEY=${BLOB_STORAGE_ACCESS_KEY}
- S3_ACCESS_KEY_SECRET=${BLOB_STORAGE_ACCESS_KEY_SECRET}
- FF_CH_SEARCH_ENABLED=${CH_SEARCH_ENABLED:-true}
- BASIC_AUTH_ENABLED=${BASIC_AUTH_ENABLED:-false}
- BASIC_AUTH_JWT_SECRET=${BASIC_AUTH_JWT_SECRET}
- TRACE_TIER_TTL_DURATION_SEC_MAP=${TRACE_TIER_TTL_DURATION_SEC_MAP}
command:
- "saq"
- "app.workers.queues.single_queue_worker.settings"
- "--quiet"
depends_on:
langchain-db:
condition: service_healthy
langchain-redis:
condition: service_healthy
clickhouse-setup:
condition: service_completed_successfully
postgres-setup:
condition: service_completed_successfully
restart: always
langchain-db:
image: ${_REGISTRY:-docker.io}/postgres:14.7
command:
[
"postgres",
"-c",
"log_min_messages=WARNING",
"-c",
"client_min_messages=WARNING",
]
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
volumes:
- langchain-db-data:/var/lib/postgresql/data
ports:
- 5433:5432
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
interval: 2s
timeout: 2s
retries: 30
langchain-redis:
image: ${_REGISTRY:-docker.io}/redis:7
ports:
- 63791:6379
volumes:
- langchain-redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 2s
timeout: 2s
retries: 30
langchain-clickhouse:
image: ${_REGISTRY:-docker.io}/clickhouse/clickhouse-server:24.8
user: "101:101"
restart: always
environment:
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-default}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-password}
volumes:
- langchain-clickhouse-data:/var/lib/clickhouse
- ./users.xml:/etc/clickhouse-server/users.d/users.xml
ports:
- 8124:8123
- 9001:9000
healthcheck:
test: ["CMD", "clickhouse-client", "--query", "SELECT 1"]
interval: 2s
timeout: 2s
retries: 30
clickhouse-setup:
image: ${_REGISTRY:-docker.io}/langchain/langsmith-backend:${_LANGSMITH_IMAGE_VERSION:-0.11.4}
depends_on:
langchain-clickhouse:
condition: service_healthy
restart: "on-failure:10"
environment:
- CLICKHOUSE_HOST=${CLICKHOUSE_HOST:-langchain-clickhouse}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-password}
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-default}
- CLICKHOUSE_PORT=${CLICKHOUSE_PORT:-8123}
- CLICKHOUSE_NATIVE_PORT=${CLICKHOUSE_NATIVE_PORT:-9000}
- CLICKHOUSE_TLS=${CLICKHOUSE_TLS:-false}
command:
[
"bash",
"scripts/wait_for_clickhouse_and_migrate.sh"
]
postgres-setup:
image: ${_REGISTRY:-docker.io}/langchain/langsmith-backend:${_LANGSMITH_IMAGE_VERSION:-0.11.4}
depends_on:
langchain-db:
condition: service_healthy
environment:
- LANGCHAIN_ENV=local_docker
- LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
- LOG_LEVEL=${LOG_LEVEL:-warning}
- AUTH_TYPE=${AUTH_TYPE:-none}
- OAUTH_CLIENT_ID=${OAUTH_CLIENT_ID}
- OAUTH_ISSUER_URL=${OAUTH_ISSUER_URL}
- API_KEY_SALT=${API_KEY_SALT}
- POSTGRES_DATABASE_URI=${POSTGRES_DATABASE_URI:-postgres:postgres@langchain-db:5432/postgres}
- REDIS_DATABASE_URI=${REDIS_DATABASE_URI:-redis://langchain-redis:6379}
- MAX_ASYNC_JOBS_PER_WORKER=${MAX_ASYNC_JOBS_PER_WORKER:-10}
- ASYNCPG_POOL_MAX_SIZE=${ASYNCPG_POOL_MAX_SIZE:-3}
- CLICKHOUSE_HOST=${CLICKHOUSE_HOST:-langchain-clickhouse}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-password}
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-default}
- CLICKHOUSE_PORT=${CLICKHOUSE_PORT:-8123}
- CLICKHOUSE_NATIVE_PORT=${CLICKHOUSE_NATIVE_PORT:-9000}
- CLICKHOUSE_TLS=${CLICKHOUSE_TLS:-false}
restart: "on-failure:10"
command:
[
"bash",
"-c",
"alembic upgrade head",
]
volumes:
langchain-db-data:
langchain-redis-data:
langchain-clickhouse-data:

.env

# Don't change this file. Instead, copy it to .env and change the values there. The default values will work out of the box as long as you provide your license key.
_REGISTRY=docker.io # Change to your desired Docker registry if you are using a private registry. Otherwise, leave it as is
_LANGSMITH_IMAGE_VERSION=0.11.3 # Change to the desired Langsmith image version
LANGSMITH_LICENSE_KEY= # Change to your Langsmith license key
AUTH_TYPE=none # Set to oauth if you want to use OAuth2.0 with PKCE. Set to mixed for basic auth or OAuth2.0 with OAuth2.0 client secret
OAUTH_CLIENT_ID="" # Required if AUTH_TYPE=oauth or mixed with OAuth2.0 with OAuth2.0 client secret
OAUTH_ISSUER_URL="" # Required if AUTH_TYPE=oauth or mixed with OAuth2.0 with OAuth2.0 client secret (https://your-issuer-url)
OAUTH_CLIENT_SECRET="" # Required if AUTH_TYPE=none with OAuth2.0 with OAuth2.0 client secret
LANGSMITH_URL=http://localhost:1980 # Change to your hosted Langsmith URL. Required if AUTH_TYPE=none with OAuth2.0 client secret
API_KEY_SALT=langsmith-secret-key-2024-random-salt-value-for-testing # Change to your desired API key salt. Can be any random value. Must be set if AUTH_TYPE=oauth
POSTGRES_DATABASE_URI=postgres:postgres@langchain-db:5432/postgres # Change to your database URI if using external postgres. Otherwise, leave it as is
REDIS_DATABASE_URI=redis://langchain-redis:6379 # Change to your Redis URI if using external Redis. Otherwise, leave it as is
LOG_LEVEL=info # Change to your desired log level
MAX_ASYNC_JOBS_PER_WORKER=10 # Change to your desired maximum async jobs per worker. We recommend 10/suggest spinning up more replicas of the queue worker if you need more throughput
ASYNCPG_POOL_MAX_SIZE=3 # Change the PG pool size based off your pg instance/requirements.
CLICKHOUSE_HOST=langchain-clickhouse # Change to your Clickhouse host if using external Clickhouse. Otherwise, leave it as is
CLICKHOUSE_USER=default # Change to your Clickhouse user if needed
CLICKHOUSE_DB=default # Change to your Clickhouse database if needed
CLICKHOUSE_PORT=8123 # Change to your Clickhouse port if needed
CLICKHOUSE_TLS=false # Change to true if you are using TLS to connect to Clickhouse. Otherwise, leave it as is
CLICKHOUSE_CLUSTER= # Change to your Clickhouse cluster if using a replicated cluster. Otherwise, leave it as is
CLICKHOUSE_PASSWORD=password # Change to your Clickhouse password if needed
CLICKHOUSE_NATIVE_PORT=9000 # Change to your Clickhouse native port if needed
ORG_CREATION_DISABLED=false # Set to true if you want to disable org creation
WORKSPACE_SCOPE_ORG_INVITES_ENABLED=false # Set to true if you want to disable workspace scope org invites
PERSONAL_ORGS_DISABLED=false # Set to true if you want to disable personal orgs
TTL_ENABLED=true # Set to true if you want to enable TTL for your data
TRACE_TIER_TTL_DURATION_SEC_MAP='{"longlived":34560000,"shortlived":1209600}'
BLOB_STORAGE_ENABLED=false # Set to true if you want to enable blob storage
BLOB_STORAGE_BUCKET_NAME=langsmith-blob-storage # Change to your desired blob storage bucket name
BLOB_STORAGE_API_URL=https://s3.us-west-2.amazonaws.com # Change to your desired blob storage API URL
BLOB_STORAGE_ACCESS_KEY=your-access-key # Change to your desired blob storage access key
BLOB_STORAGE_ACCESS_KEY_SECRET=your-access-key-secret # Change to your desired blob storage access key secret
CH_SEARCH_ENABLED=true # Set to false if you do not want to store tokenized inputs/outputs in clickhouse
BASIC_AUTH_ENABLED=false # Set to true if you want to enable basic auth
BASIC_AUTH_JWT_SECRET=langsmith-jwt-secret-key-2024-random-value-for-testing # Change to your desired basic auth JWT secret
INITIAL_ORG_ADMIN_EMAIL=admin@example.com # Change to your desired initial org admin email. Only used if BASIC_AUTH_ENABLED=false
INITIAL_ORG_ADMIN_PASSWORD=AdminPassword123! # Change to your desired initial org admin password. Needs to be at least 12 characters long, contain at least one lowercase, one uppercase, and one special character. Only used if BASIC_AUTH_ENABLED=falseLANGSMITH_API_KEY=sk-test-key-2024
LANGCHAIN_TRACING_V2=false
DISABLE_AUTH=true
PUBLIC_ACCESS=true
ALLOW_ANONYMOUS_ACCESS=true
LANGSMITH_PUBLIC=true
SKIP_AUTH=true
AUTH_ENABLED=false
LANGSMITH_SELF_HOSTED=true
TENANT_CREATION_DISABLED=false
ENABLE_FREE_TIER=true
LANGSMITH_DEFAULT_TENANT=default
LANGSMITH_DEFAULT_ORG=default-org
AUTO_CREATE_TENANT=true

users.xml

<clickhouse>
<users>
<default>
<access_management>1</access_management>
<named_collection_control>1</named_collection_control>
<show_named_collections>1</show_named_collections>
<show_named_collections_secrets>1</show_named_collections_secrets>
<profile>default</profile>
</default>
</users>
<profiles>
<default>
<async_insert>1</async_insert>
<async_insert_max_data_size>2000000</async_insert_max_data_size>
<wait_for_async_insert>0</wait_for_async_insert>
<parallel_view_processing>1</parallel_view_processing>
<materialize_ttl_after_modify>0</materialize_ttl_after_modify>
<wait_for_async_insert_timeout>25</wait_for_async_insert_timeout>
<allow_simdjson>0</allow_simdjson>
<lightweight_deletes_sync>0</lightweight_deletes_sync>
</default>
</profiles>
</clickhouse>

启动

docker-compose up

访问下面的界面 

 LANGSMITH_LICENSE_KEY  这个目前是需要联系 官网的销售团队  Talk to our team 点击链接[[Talk to our team]去填写信息

三 k8s 部署 langsmith 

3.1 minikube安装 k8s

minikube 是一个工具, 能让你在本地运行 Kubernetes。 minikube 在你的个人计算机(包括 Windows、macOS 和 Linux PC)上运行一个一体化(all-in-one) 或多节点的本地 Kubernetes 集群,以便你来尝试 Kubernetes 或者开展每天的开发工作。

安装命令

winget install Kubernetes.minikube

以管理员身份启动一个cmd

3.2 输入  minikube start 启动群集

3.3 安装 kubectl 

下载

curl.exe -LO "https://dl.k8s.io/release/v1.34.0/bin/windows/amd64/kubectl.exe"

放到D:\kubectl, 然后设置环境变量

查看你 kubectl 的版本

3.4 安装 helm

choco install kubernetes-helm

生成 Api Key Salt

C:\Users\Administrator>openssl rand -base64 32

dXZFfZy9c0m16eIi9Vyqe1IuaXuCVDNbsmU/X7Sg5FE=

生成JWT Secret 

C:\Users\Administrator>openssl rand -base64 32

8DvHV/Am3DVk6eWMiQxiLFZd0OTiCh2LgZ5IX2Wv658=

添加 Helm 仓库

helm repo add langchain langchain-ai.github.io/helm/

查找最新版本

helm search repo langchain/langsmith --versions

langchain/langsmith                     0.12.3          0.12.10         Helm chart to deploy the langsmith application ...
langchain/langsmith                     0.12.2          0.12.10         Helm chart to deploy the langsmith application ...
langchain/langsmith                     0.12.1          0.12.10         Helm chart to deploy the langsmith application ...
langchain/langsmith                     0.12.0          0.12.10         Helm chart to deploy the langsmith application ...
langchain/langsmith                     0.11.29         0.12.4          Helm chart to deploy the langsmith application ...
langchain/langsmith                     0.11.28         0.12.4          Helm chart to deploy the langsmith application ...

新建一个 langsmith_config.yaml

config:
langsmithLicenseKey: "<your-license-key>"  这里需要自己申请的key
apiKeySalt: "dXZFfZy9c0m16eIi9Vyqe1IuaXuCVDNbsmU/X7Sg5FE="
authType: mixed
basicAuth:
enabled: true
initialOrgAdminEmail: "admin@example.com"
initialOrgAdminPassword: "YourSecurePassword123!"
jwtSecret: "8DvHV/Am3DVk6eWMiQxiLFZd0OTiCh2LgZ5IX2Wv658="

为 Minikube 启用默认存储类

安装/升级 LangSmith

helm upgrade -i langsmith langchain/langsmith --values langsmith_config.yaml --version 0.12.2 --debug

备注 如果失败了,ctrl+c结束

先需要执行kubectl delete pvc -l app.kubernetes.io/instance=langsmith   进行删除 ,然后清理当前失败的部署:helm uninstall langsmith

检查部署状态

kubectl get pods -w
langsmith-backend-6ff46c99c4-wz22d       1/1     Running   0          3h2m
langsmith-frontend-6bbb94c5df-8xrlr      1/1     Running   0          3h2m
langsmith-hub-backend-5cc68c888c-vppjj   1/1     Running   0          3h2m
langsmith-playground-6d95fd8dc6-x2d9b    1/1     Running   0          3h2m
langsmith-postgres-0                     1/1     Running   0          9h
langsmith-queue-5898b9d566-tv6q8         1/1     Running   0          3h2m
langsmith-redis-0                        1/1     Running   0          9h

kubectl get services

NAME                    TYPE           CLUSTER-IP       EXTERNAL-IP                                                               PORT(S)        AGE
langsmith-backend       ClusterIP      172.20.140.77    <none>                                                                    1984/TCP       35h
langsmith-frontend      LoadBalancer   172.20.253.251   <external ip>                                                             80:31591/TCP   35h
langsmith-hub-backend   ClusterIP      172.20.112.234   <none>                                                                    1985/TCP       35h
langsmith-playground    ClusterIP      172.20.153.194   <none>                                                                    3001/TCP       9h
langsmith-postgres      ClusterIP      172.20.244.82    <none>                                                                    5432/TCP       35h
langsmith-redis         ClusterIP      172.20.81.217    <none>                                                                    6379/TCP       35h

浏览器访问 langsmith-frontend界面

 LANGSMITH_LICENSE_KEY  这个目前是需要联系 官网的销售团队  Talk to our team 点击链接[Talk to our team]去填写信息

总结: 独立服务器(standalone server) 对于日常的开发是足够的, 还可以搭云端的langsmith来使用。

  本地的langsmith和langsmith with deployment 不建议本地安装,第一个原因是机器的硬件要求:docker安装建议4 vCPUs, 16GB Memory available on your machine;k8s安装建议Recommended: At least 16 vCPUs, 64GB Memory available; 第二个原因 是不同机器环境配置,会出现的错误会很多,按照步骤也会遇到新的问题,需要自己根据实际情况去解决。第三个原因是需要企业级, 需要申请 LANGSMITH_LICENSE_KEY 认证许可。 langsmith这个适合企业 公司按照,个人开发没必要那么费劲折腾。