AGENT SKILL

langchain-deploy-integration

Deploy LangChain integrations to production environments. Use when deploying to cloud platforms, configuring containers, or setting up production infrastructure for LangChain apps. Trigger with phrases like "deploy langchain", "langchain production deploy", "langchain cloud run", "langchain docker", "langchain kubernetes".

License 许可
MIT
最近更新
2026-05-26
Stars
★ 0
Forks
0

01 前言 Front Matter

name
langchain-deploy-integration
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Deploy LangChain integrations to production environments. Use when deploying to cloud platforms, configuring containers, or setting up production infrastructure for LangChain apps. Trigger with phrases like "deploy langchain", "langchain production deploy", "langchain cloud run", "langchain docker", "langchain kubernetes".
allowed-tools
Read, Write, Edit, Bash(docker:*), Bash(gcloud:*)
compatible-with
claude-code, codex, openclaw

03 SKILL.md 正文

LangChain Deploy Integration

Overview

Deploy LangChain applications to production using LangServe, Docker, and cloud platforms. Covers containerization of chains and agents, LangServe API deployment, and integration with LangSmith for production observability.

Prerequisites

  • LangChain application with chains/agents defined
  • Docker installed for containerization
  • LangSmith API key for production tracing
  • Platform CLI (gcloud, aws, or docker compose)

Instructions

Step 1: LangServe API Setup

# serve.py
from fastapi import FastAPI
from langserve import add_routes
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

app = FastAPI(title="LangChain API")

# Define your chain
prompt = ChatPromptTemplate.from_template("Answer: {question}")
chain = prompt | ChatOpenAI(model="gpt-4o-mini")

# Add LangServe routes
add_routes(app, chain, path="/chat")

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)  # 8000: API server port

Step 2: Dockerfile

FROM python:3.11-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

ENV LANGCHAIN_TRACING_V2=true
ENV LANGCHAIN_PROJECT=production

EXPOSE 8000  # 8000: API server port
CMD ["uvicorn", "serve:app", "--host", "0.0.0.0", "--port", "8000"]  # API server port

Step 3: Docker Compose for Development

version: "3.8"
services:
  langchain-api:
    build: .
    ports:
      - "8000:8000"  # 8000: API server port
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - LANGCHAIN_API_KEY=${LANGCHAIN_API_KEY}
      - LANGCHAIN_TRACING_V2=true
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]  # API server port
      interval: 30s

Step 4: Cloud Run Deployment

gcloud run deploy langchain-api \
  --source . \
  --region us-central1 \
  --set-secrets=OPENAI_API_KEY=openai-key:latest \
  --set-secrets=LANGCHAIN_API_KEY=langsmith-key:latest \
  --set-env-vars=LANGCHAIN_TRACING_V2=true \
  --min-instances=1 \
  --memory=1Gi

Step 5: Health Check with LangSmith

from langsmith import Client

async def health_check():
    try:
        client = Client()
        # Verify LangSmith connection
        client.list_projects(limit=1)
        return {"status": "healthy", "tracing": "enabled"}
    except Exception as e:
        return {"status": "degraded", "error": str(e)}

Error Handling

Issue Cause Solution
Import errors Missing dependencies Pin versions in requirements.txt
LangSmith timeout Network issue Set LANGCHAIN_TRACING_V2=false as fallback
Memory exceeded Large context Increase container memory, use streaming
Cold start slow Heavy imports Use gunicorn with preload

Examples

Production Requirements

langchain>=0.3.0
langchain-openai>=0.2.0
langserve>=0.3.0
langsmith>=0.1.0
uvicorn>=0.30.0
fastapi>=0.115.0

Resources

Next Steps

For multi-environment setup, see langchain-multi-env-setup.

Output

  • Configuration files or code changes applied to the project
  • Validation report confirming correct implementation
  • Summary of changes made and their rationale

04 同仓库更多 Skills

SamuelChien
SamuelChien/mega-skills-collection

zustand-store-ts

Create Zustand stores with TypeScript, subscribeWithSelector middleware, and proper state/action separation. Use when building React state management, creating global stores, or implementing reactive state patterns with Zustand.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zustand-store-creator

Zustand Store Creator - Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zero-trust-config-helper

Zero Trust Config Helper - Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zapier-integration-helper

Zapier Integration Helper - Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

zai-cli

Execute z.AI CLI providing vision, search, reader, and GitHub exploration via CLI and MCP. Use when user needs image/video analysis, OCR, UI-to-code conversion, error diagnosis, real-time web search, web page to markdown extraction, or GitHub code exploration. Trigger with phrases like "analyze this image", "search the web for", "read this page", "explore this repo", or "use zai". Requires Z_AI_API_KEY.

★ 0
SamuelChien
SamuelChien/mega-skills-collection

yt-research

Research competitor YouTube channels, niches, and trending topics for your content strategy. Use this skill whenever the user says "research channels", "analyze competitors", "find trending topics", "niche analysis", "competitive research", "what are other creators doing", "scrape YouTube channels", or wants to understand the competitive landscape for a specific tool or topic area. Use when working with yt research. Trigger with 'yt', 'research'.

★ 0