Skip to content

Commit

Permalink
remove responses parameter from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-risch committed Apr 9, 2024
1 parent 8260b42 commit 95d27b9
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions test/components/evaluators/test_context_relevance_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_init_default(self, monkeypatch):
"Second, calculate a relevance score for each statement in the context. "
"The score is 1 if the statement is relevant to answer the question or 0 if it is not relevant."
)
assert component.inputs == [("questions", List[str]), ("contexts", List[List[str]]), ("responses", List[str])]
assert component.inputs == [("questions", List[str]), ("contexts", List[List[str]])]
assert component.outputs == ["statements", "statement_scores"]
assert component.examples == [
{
Expand Down Expand Up @@ -54,15 +54,15 @@ def test_init_with_parameters(self):
api_key=Secret.from_token("test-api-key"),
api="openai",
examples=[
{"inputs": {"responses": "Damn, this is straight outta hell!!!"}, "outputs": {"custom_score": 1}},
{"inputs": {"responses": "Football is the most popular sport."}, "outputs": {"custom_score": 0}},
{"inputs": {"questions": "Damn, this is straight outta hell!!!"}, "outputs": {"custom_score": 1}},
{"inputs": {"questions": "Football is the most popular sport."}, "outputs": {"custom_score": 0}},
],
)
assert component.generator.client.api_key == "test-api-key"
assert component.api == "openai"
assert component.examples == [
{"inputs": {"responses": "Damn, this is straight outta hell!!!"}, "outputs": {"custom_score": 1}},
{"inputs": {"responses": "Football is the most popular sport."}, "outputs": {"custom_score": 0}},
{"inputs": {"questions": "Damn, this is straight outta hell!!!"}, "outputs": {"custom_score": 1}},
{"inputs": {"questions": "Football is the most popular sport."}, "outputs": {"custom_score": 0}},
]

def test_from_dict(self, monkeypatch):
Expand All @@ -73,15 +73,13 @@ def test_from_dict(self, monkeypatch):
"init_parameters": {
"api_key": {"env_vars": ["OPENAI_API_KEY"], "strict": True, "type": "env_var"},
"api": "openai",
"examples": [{"inputs": {"responses": "Football is the most popular sport."}, "outputs": {"score": 0}}],
"examples": [{"inputs": {"questions": "What is football?"}, "outputs": {"score": 0}}],
},
}
component = ContextRelevanceEvaluator.from_dict(data)
assert component.api == "openai"
assert component.generator.client.api_key == "test-api-key"
assert component.examples == [
{"inputs": {"responses": "Football is the most popular sport."}, "outputs": {"score": 0}}
]
assert component.examples == [{"inputs": {"questions": "What is football?"}, "outputs": {"score": 0}}]

def test_run_calculates_mean_score(self, monkeypatch):
monkeypatch.setenv("OPENAI_API_KEY", "test-api-key")
Expand Down Expand Up @@ -109,11 +107,7 @@ def generator_run(self, *args, **kwargs):
"programmers write clear, logical code for both small and large-scale software projects."
],
]
responses = [
"Football is the most popular sport with around 4 billion followers worldwide.",
"Python is a high-level general-purpose programming language that was created by George Lucas.",
]
results = component.run(questions=questions, contexts=contexts, responses=responses)
results = component.run(questions=questions, contexts=contexts)
assert results == {
"individual_scores": [0.5, 1],
"results": [
Expand Down

0 comments on commit 95d27b9

Please sign in to comment.