Bird
Raised Fist0
LangChainframework~20 mins

LangChain ecosystem (LangSmith, LangGraph, LangServe) - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
LangChain Ecosystem Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
1:30remaining
What is the primary role of LangSmith in the LangChain ecosystem?

LangSmith is a part of the LangChain ecosystem. What does it mainly help developers do?

AIt serves as a hosting platform for deploying language model APIs.
BIt provides tools for tracking, evaluating, and debugging language model runs.
CIt is a visualization tool for creating flowcharts of language model chains.
DIt is a database system optimized for storing large text corpora.
Attempts:
2 left
💡 Hint

Think about monitoring and improving model outputs.

📝 Syntax
intermediate
2:00remaining
Which code snippet correctly creates a LangGraph to visualize a chain?

Choose the code that correctly initializes a LangGraph object and adds a simple chain for visualization.

A
from langchain.graphs import LangGraph
graph = LangGraph()
graph.add_chain(my_chain)
graph.render()
B
from langchain.graph import LangGraph
graph = LangGraph()
graph.add(my_chain)
graph.show()
C
import langchain.graphs as lg
graph = lg.LangGraph()
graph.insert_chain(my_chain)
graph.display()
D
from langchain.graphs import LangGraph
graph = LangGraph(my_chain)
graph.render()
Attempts:
2 left
💡 Hint

Check the correct import path and method names for LangGraph.

state_output
advanced
2:00remaining
What is the output of this LangServe server code when a POST request with text 'Hello' is sent?

Consider this LangServe server code snippet:

from langchain.servers import LangServe

app = LangServe()

@app.route('/process')
async def process(request):
    data = await request.json()
    text = data.get('text', '')
    return {'response': text.upper()}

What will the server respond with when it receives a POST request to '/process' with JSON body {"text": "Hello"}?

LangChain
from langchain.servers import LangServe

app = LangServe()

@app.route('/process')
async def process(request):
    data = await request.json()
    text = data.get('text', '')
    return {'response': text.upper()}
ATypeError: 'NoneType' object is not subscriptable
B{"response": "Hello"}
C{"response": "HELLO"}
DSyntaxError: invalid syntax in async function
Attempts:
2 left
💡 Hint

Look at how the text is transformed before returning.

🔧 Debug
advanced
2:00remaining
Which option causes a runtime error when using LangSmith to log a run?

Given this code snippet to log a run in LangSmith:

from langchain_experimental.langsmith import Client
client = Client()
run = client.start_run(name="TestRun")
run.log_output(output)
run.end()

Which option below will cause a runtime error?

LangChain
from langchain_experimental.langsmith import Client
client = Client()
run = client.start_run(name="TestRun")
run.log_output(output)
run.end()
Aoutput is an integer and run.log_output(output) works fine.
Boutput is a string 'Result data' and run.log_output(output) works fine.
Coutput is a dictionary and run.log_output(output) works fine.
Doutput is None and run.log_output(output) raises AttributeError.
Attempts:
2 left
💡 Hint

Consider what happens if output is None when calling log_output.

🧠 Conceptual
expert
2:30remaining
How do LangServe and LangGraph complement each other in a LangChain application?

In a LangChain app, LangServe is used to deploy language model APIs, and LangGraph is used to visualize chains. How do these two components work together effectively?

ALangServe hosts the API endpoints while LangGraph helps developers visualize and debug the chain flows that the API serves.
BLangServe automatically generates graphs for LangGraph to display without developer input.
CLangGraph deploys the API and LangServe visualizes the chain execution.
DLangServe and LangGraph are unrelated and cannot be used together.
Attempts:
2 left
💡 Hint

Think about deployment vs visualization roles.

Practice

(1/5)
1. Which LangChain ecosystem tool is primarily used to track and log your language app runs?
easy
A. LangFlow
B. LangGraph
C. LangServe
D. LangSmith

Solution

  1. 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.
  2. Final Answer:

    LangSmith -> Option D
  3. Quick Check:

    Tracking runs = LangSmith [OK]
Hint: Remember: Smith = logs and tracks runs [OK]
Common Mistakes:
  • Confusing LangGraph with logging tool
  • Thinking LangServe handles logging
  • Assuming LangFlow is part of LangChain ecosystem
2. Which of the following is the correct way to start LangServe to deploy your app?
easy
A. langsmith deploy my_app.py
B. langserve start --app my_app.py
C. langgraph visualize my_app.py
D. serve langchain --run my_app.py

Solution

  1. Step 1: Identify LangServe command syntax and eliminate incorrect commands

    LangServe uses the command langserve start --app <file> to deploy an app. Other options use wrong tool names or commands not related to LangServe.
  2. Final Answer:

    langserve start --app my_app.py -> Option B
  3. Quick Check:

    Deploy app = langserve start [OK]
Hint: Deploy apps with 'langserve start --app' command [OK]
Common Mistakes:
  • Using langsmith or langgraph commands to deploy
  • Mixing command order or flags
  • Assuming 'serve langchain' is valid
3. Given this code snippet using LangGraph:
from langchain.tools import LangGraph
graph = LangGraph(app=my_app)
graph.show()

What will happen when graph.show() is called?
medium
A. It visually displays the language task flow of the app
B. It logs the app run details to LangSmith dashboard
C. It deploys the app to a server for sharing
D. It raises a syntax error due to missing parameters

Solution

  1. 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. Calling graph.show() triggers the visual display of the app's task graph, not logging or deployment.
  2. Final Answer:

    It visually displays the language task flow of the app -> Option A
  3. Quick Check:

    graph.show() = visual flow display [OK]
Hint: LangGraph = visualize app flow, show() displays it [OK]
Common Mistakes:
  • Confusing visualization with logging
  • Thinking it deploys the app
  • Assuming code has syntax errors
4. You wrote this code to deploy your app with LangServe:
import langserve
langserve.run('my_app.py')

But it raises an error. What is the likely cause?
medium
A. The method 'run' does not exist in LangServe; use 'start' instead
B. You must import LangSmith, not LangServe, to deploy apps
C. The filename must be a module, not a string
D. LangServe requires a config file, missing here

Solution

  1. 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.
  2. Final Answer:

    The method 'run' does not exist in LangServe; use 'start' instead -> Option A
  3. Quick Check:

    Use 'start' method, not 'run' [OK]
Hint: LangServe uses 'start', not 'run' to deploy [OK]
Common Mistakes:
  • Using 'run' instead of 'start'
  • Confusing LangSmith with LangServe
  • Thinking filename must be a module object
5. You want to build a language app that you can deploy, track, and visualize easily. Which sequence of LangChain ecosystem tools should you use?
hard
A. Use LangGraph to deploy, LangServe to track runs, and LangSmith to visualize flow
B. Use LangSmith to deploy, LangGraph to track runs, and LangServe to visualize flow
C. Use LangServe to deploy, LangSmith to track runs, and LangGraph to visualize flow
D. Use LangServe to track runs, LangGraph to deploy, and LangSmith to visualize flow

Solution

  1. 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.
  2. Final Answer:

    Use LangServe to deploy, LangSmith to track runs, and LangGraph to visualize flow -> Option C
  3. Quick Check:

    Deploy, track, visualize = Serve, Smith, Graph [OK]
Hint: Deploy with Serve, track with Smith, visualize with Graph [OK]
Common Mistakes:
  • Mixing up tool roles
  • Using LangSmith for deployment
  • Assuming LangGraph tracks runs