0d3cb498a3
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
68 lines
1.5 KiB
Markdown
68 lines
1.5 KiB
Markdown
# integration-langgraph (LangGraph Integration)
|
||
|
||
This example demonstrates how to use LangGraph with Promptfoo, including a research agent setup, structured output, and red teaming or evaluation.
|
||
|
||
You can run this example with:
|
||
|
||
```bash
|
||
npx promptfoo@latest init --example integration-langgraph
|
||
cd integration-langgraph
|
||
```
|
||
|
||
## Environment Variables
|
||
|
||
This example requires the following environment variables:
|
||
|
||
- `OPENAI_API_KEY` – Your OpenAI API key (required by LangGraph to use ChatOpenAI)
|
||
|
||
You can set this in a `.env` file or directly in your environment.
|
||
|
||
## Prerequisites
|
||
|
||
- Python 3.9-3.12 tested
|
||
- Node.js v22 LTS or newer
|
||
- OpenAI API access (for GPT-4o, GPT-4o-mini, and OpenAI's forthcoming o3 mini once released)
|
||
- An OpenAI API key
|
||
|
||
Install Python packages:
|
||
|
||
```bash
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
Or install individually:
|
||
|
||
```bash
|
||
pip install langgraph langchain langchain-openai python-dotenv
|
||
```
|
||
|
||
Install promptfoo CLI:
|
||
|
||
```bash
|
||
npm install -g promptfoo
|
||
```
|
||
|
||
## Files
|
||
|
||
- `agent.py`: Defines the LangGraph Research Agent, using a StateGraph that processes user queries and summarizes AI research trends.
|
||
- `provider.py`: Wraps the agent logic into a callable function for Promptfoo, exposing a call_api() handler.
|
||
- `promptfooconfig.yaml`: Configures Promptfoo to:
|
||
|
||
- Provide test prompts
|
||
- Call the LangGraph provider
|
||
- Check outputs using assertions
|
||
|
||
Run the evaluation:
|
||
|
||
```bash
|
||
npx promptfoo eval
|
||
```
|
||
|
||
Explore results in browser:
|
||
|
||
```bash
|
||
npx promptfoo view
|
||
```
|
||
|
||
---
|