Skip to content

Commit

Permalink
[Evaluation] Pass in seed directly (#24403)
Browse files Browse the repository at this point in the history
adding test rn
  • Loading branch information
hinthornw authored Jul 19, 2024
1 parent 62b6965 commit 0ee6ed7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/langchain/langchain/evaluation/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def load_evaluator(
)

llm = llm or ChatOpenAI( # type: ignore[call-arg]
model="gpt-4", model_kwargs={"seed": 42}, temperature=0
model="gpt-4", seed=42, temperature=0
)
except Exception as e:
raise ValueError(
Expand Down
15 changes: 15 additions & 0 deletions libs/langchain/tests/unit_tests/evaluation/qa/test_eval_chain.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"""Test LLM Bash functionality."""

import os
import sys
from typing import Type
from unittest.mock import patch

import pytest

from langchain.chains.llm import LLMChain
from langchain.evaluation.loading import load_evaluator
from langchain.evaluation.qa.eval_chain import (
ContextQAEvalChain,
CotQAEvalChain,
Expand Down Expand Up @@ -50,6 +53,18 @@ def test_context_eval_chain(chain_cls: Type[ContextQAEvalChain]) -> None:
assert outputs[0]["text"] == "foo"


def test_load_criteria_evaluator() -> None:
"""Test loading a criteria evaluator."""
try:
from langchain_openai import ChatOpenAI # noqa: F401
except ImportError:
pytest.skip("langchain-openai not installed")
# Patch the env with an openai-api-key
with patch.dict(os.environ, {"OPENAI_API_KEY": "foo"}):
# Check it can load using a string arg (even if that's not how it's typed)
load_evaluator("criteria") # type: ignore


@pytest.mark.parametrize("chain_cls", [QAEvalChain, ContextQAEvalChain, CotQAEvalChain])
def test_implements_string_evaluator_protocol(
chain_cls: Type[LLMChain],
Expand Down

0 comments on commit 0ee6ed7

Please sign in to comment.