The LangChain ecosystem helps you build, test, and run language AI apps easily. It gives tools to track your work, visualize how your app thinks, and serve your app to users.
LangChain ecosystem (LangSmith, LangGraph, LangServe)
Start learning this pattern below
Jump into concepts and practice - no test required
from langsmith import Client as LangSmith from langgraph.graph import StateGraph as LangGraph from langserve import add_routes from fastapi import FastAPI # LangSmith for tracking langsmith = LangSmith(api_key="your_api_key") # LangGraph for building graphs langgraph = LangGraph() # LangServe for deployment app = FastAPI() add_routes(app, chain, path="/chain") if __name__ == "__main__": import uvicorn uvicorn.run(app, port=8000)
LangSmith: Use the Client for tracing runs.
LangGraph: Build stateful multi-actor apps with graphs.
LangServe: Deploy chains as REST APIs using FastAPI.
Install with: pip install langsmith langgraph langserve fastapi uvicorn
from langsmith import traceable @traceable def my_function(input): return input.upper() result = my_function("hello")
from langgraph.graph import StateGraph, END graph = StateGraph(state_schema=dict) graph.add_node("node", func) graph.set_entry_point("node") graph.add_edge("node", END) app = graph.compile()
from langserve import add_routes from fastapi import FastAPI from langchain_core.prompts import ChatPromptTemplate app = FastAPI() chain = ChatPromptTemplate.from_template("Tell me about {topic}") add_routes(app, chain, path="/template") # Run with: uvicorn main:app --reload
Demonstrates traceable chain with LangSmith, simple LangGraph app. Note: Requires OPENAI_API_KEY and LANGCHAIN_API_KEY env vars for tracing. LangServe setup shown in syntax.
from langsmith import traceable from langgraph.graph import StateGraph, END from langchain_core.prompts import ChatPromptTemplate from langchain_openai import ChatOpenAI @traceable class SimpleChain: def __init__(self): self.llm = ChatOpenAI(model_name="gpt-3.5-turbo") self.prompt = ChatPromptTemplate.from_template("Uppercase: {input}") self.chain = self.prompt | self.llm def run(self, input_text): return self.chain.invoke({"input": input_text}).content # LangGraph example (simple) graph = StateGraph(str) graph.add_node("uppercase", lambda x: x.upper()) graph.set_entry_point("uppercase") graph.add_edge("uppercase", END) app = graph.compile() simple_chain = SimpleChain() input_text = "hello world" output_text = simple_chain.run(input_text) print(f"Input: {input_text}") print(f"Output: {output_text}") print(app.invoke("hello langgraph"))
LangSmith: Observability platform for tracing, testing, monitoring LLM apps.
LangGraph: Framework for building reliable, stateful AI agents with cycles, branching.
LangServe: Makes it easy to serve LangChain runnables as REST APIs.
All integrate seamlessly with core LangChain.
LangSmith: Tracing, datasets, evals for LLM apps.
LangGraph: Graphs for complex, cyclical agent workflows.
LangServe: Production-ready deployment of chains/runnables.
Practice
Solution
Step 1: Understand the purpose of LangSmith and differentiate from other tools
LangSmith is designed to track and log the execution of language applications, capturing run data. LangGraph visualizes app processes, and LangServe helps deploy apps, so they do not focus on logging.Final Answer:
LangSmith -> Option DQuick Check:
Tracking runs = LangSmith [OK]
- Confusing LangGraph with logging tool
- Thinking LangServe handles logging
- Assuming LangFlow is part of LangChain ecosystem
Solution
Step 1: Identify LangServe command syntax and eliminate incorrect commands
LangServe uses the commandlangserve start --app <file>to deploy an app. Other options use wrong tool names or commands not related to LangServe.Final Answer:
langserve start --app my_app.py -> Option BQuick Check:
Deploy app = langserve start [OK]
- Using langsmith or langgraph commands to deploy
- Mixing command order or flags
- Assuming 'serve langchain' is valid
from langchain.tools import LangGraph graph = LangGraph(app=my_app) graph.show()
What will happen when
graph.show() is called?Solution
Step 1: Understand LangGraph's role and analyze the code behavior
LangGraph is used to visualize how language tasks flow in an app, showing a graphical representation. Callinggraph.show()triggers the visual display of the app's task graph, not logging or deployment.Final Answer:
It visually displays the language task flow of the app -> Option AQuick Check:
graph.show() = visual flow display [OK]
- Confusing visualization with logging
- Thinking it deploys the app
- Assuming code has syntax errors
import langserve
langserve.run('my_app.py')But it raises an error. What is the likely cause?
Solution
Step 1: Check LangServe API usage and confirm other options
LangServe does not have a 'run' method; the correct command is 'start' to deploy apps. Importing LangSmith is unrelated to deployment, filename as string is valid, and config file is optional.Final Answer:
The method 'run' does not exist in LangServe; use 'start' instead -> Option AQuick Check:
Use 'start' method, not 'run' [OK]
- Using 'run' instead of 'start'
- Confusing LangSmith with LangServe
- Thinking filename must be a module object
Solution
Step 1: Match each tool to its function and arrange tools in correct usage order
LangServe deploys apps, LangSmith tracks and logs runs, LangGraph visualizes the app's task flow. First deploy with LangServe, then track runs with LangSmith, and visualize with LangGraph.Final Answer:
Use LangServe to deploy, LangSmith to track runs, and LangGraph to visualize flow -> Option CQuick Check:
Deploy, track, visualize = Serve, Smith, Graph [OK]
- Mixing up tool roles
- Using LangSmith for deployment
- Assuming LangGraph tracks runs
