Prompt Chain

Test LangChain pipelines against multiple LLM providers

Compare LangChain LCEL chains against LLM providers using Promptfoo to validate prompt pipelines and output parsers before production.

Works with langchainopenaipython

76
Spark score
out of 100
Updated 19 days ago
Version 0.121.18
Models

Add to Favorites

Why it matters

Evaluate and compare LangChain Expression Language (LCEL) chains against different language models to ensure consistent performance and validate prompt-and-output-parser pipelines before deployment.

Outcomes

What it gets done

01

Run Python LangChain LCEL chains with Promptfoo evaluation framework

02

Compare GPT model performance against custom LangChain pipelines

03

Execute automated tests on math-focused prompt chains with output parsers

04

Validate LangChain integration behavior across different provider configurations

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-integration-langchain | bash

Steps

Steps in the chain

01
Initialize example project
02
Create and activate Python virtual environment
03
Install Python dependencies
04
Set OpenAI API key
05
Run evaluation

Overview

Integration Langchain

This is a working integration example that shows how to run Python LangChain Expression Language chains within Promptfoo. The example includes a comparison between GPT models and a math-focused LangChain pipeline. Use this when you need to run Python LangChain LCEL chains with Promptfoo. The example requires Python 3.10 or newer and OpenAI API credentials.

What it does

This integration example demonstrates how to run Python LangChain Expression Language (LCEL) chains within Promptfoo evaluation workflows. The example compares GPT models with a math-focused LangChain prompt-and-output-parser pipeline.

When to use - and when NOT to

Use this integration when you want to run Python LangChain LCEL chains with Promptfoo's evaluation framework. This example is specifically designed for Python LangChain implementations.

Do not use this if you're working with LangChain JavaScript/TypeScript implementations, as this example specifically targets Python LangChain. Avoid this approach if you don't need the complexity of LCEL chains and can accomplish your goals with direct LLM API calls.

Inputs and outputs

You provide a Python environment (3.10 or newer), OpenAI API credentials, and your LangChain LCEL chain definitions. The example includes requirements for dependencies and configuration for running evaluations.

You receive a working example that runs LangChain chains within Promptfoo.

Integrations

This example integrates Python LangChain Expression Language (LCEL) chains with Promptfoo's evaluation framework. It uses OpenAI models as providers. The setup requires Python 3.10+ with a virtual environment and pip-managed dependencies.

To get started, initialize the example:

npx promptfoo@latest init --example integration-langchain
cd integration-langchain

Then set up the Python environment:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Configure your OpenAI credentials:

export OPENAI_API_KEY=your-api-key

Run the evaluation:

px promptfoo eval

Who it's for

This integration example is for users who want to run Python LangChain LCEL chains with Promptfoo.

Source README

integration-langchain (Langchain Python)

You can run this example with:

npx promptfoo@latest init --example integration-langchain
cd integration-langchain

Usage

This example shows how to run a Python LangChain Expression Language (LCEL) chain with Promptfoo. It compares GPT-5 with a math-focused LangChain prompt-and-output-parser pipeline.

This example requires Python 3.10 or newer. Create and activate a virtual environment, then
install the requirements:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Set the OpenAI API key used by both providers:

export OPENAI_API_KEY=your-api-key

Then run the eval:

npx promptfoo eval

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.