chore: import upstream snapshot with attribution
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

This commit is contained in:
wehub-resource-sync
2026-07-13 13:24:08 +08:00
commit 0d3cb498a3
5438 changed files with 1316560 additions and 0 deletions
@@ -0,0 +1,2 @@
venv
__pycache__
+33
View File
@@ -0,0 +1,33 @@
# integration-langchain (Langchain Python)
You can run this example with:
```bash
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:
```sh
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
Set the OpenAI API key used by both providers:
```sh
export OPENAI_API_KEY=your-api-key
```
Then run the eval:
```bash
npx promptfoo eval
```
@@ -0,0 +1,41 @@
import os
import sys
def main() -> int:
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} <question>", file=sys.stderr)
return 1
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
print("OPENAI_API_KEY environment variable is required.", file=sys.stderr)
return 1
# Validate CLI inputs before importing optional dependencies so usage and
# configuration errors stay concise even before the example is installed.
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import PromptTemplate
from langchain_openai import OpenAI
llm = OpenAI(temperature=0, api_key=api_key)
math_chain = (
PromptTemplate.from_template(
"Solve the following math problem carefully. Return only the final answer.\n\n{question}"
)
| llm
| StrOutputParser()
)
try:
result = math_chain.invoke({"question": sys.argv[1]})
except Exception as error:
print(f"Error invoking math chain: {error}", file=sys.stderr)
return 1
print(result)
return 0
if __name__ == "__main__":
sys.exit(main())
@@ -0,0 +1 @@
{{question}}
@@ -0,0 +1,23 @@
# yaml-language-server: $schema=https://promptfoo.dev/config-schema.json
description: LangChain Python integration for prompt evaluation
prompts:
- file://prompt.txt
providers:
- openai:chat:gpt-5.4
- exec:python langchain_example.py
tests:
- vars:
question: What is the cube root of 389017?
- vars:
question: If you have 101101 in binary, what number does it represent in base 10?
- vars:
question: What is the natural logarithm (ln) of 89234?
- vars:
question: If a geometric series has a first term of 3125 and a common ratio of 0.008, what is the sum of the first 20 terms?
- vars:
question: A number in base 7 is 3526. What is this number in base 10?
- vars:
question: If a complex number is represented as 3 + 4i, what is its magnitude?
- vars:
question: What is the fourth root of 1296?
@@ -0,0 +1,3 @@
langchain-core==1.4.2
langchain-openai==1.1.14
openai==2.26.0