fix: enable any llm to run test functionality

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-02-09 21:15:54 +00:00
parent 409892d65f
commit b8a15c6115
4 changed files with 56 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ from unittest import mock
import pytest
from crewai.llm import LLM
from crewai.agent import Agent
from crewai.crew import Crew
from crewai.task import Task
@@ -23,7 +24,7 @@ class TestCrewEvaluator:
)
crew = Crew(agents=[agent], tasks=[task])
return CrewEvaluator(crew, openai_model_name="gpt-4o-mini")
return CrewEvaluator(crew, llm="gpt-4o-mini")
def test_setup_for_evaluating(self, crew_planner):
crew_planner._setup_for_evaluating()
@@ -47,6 +48,18 @@ class TestCrewEvaluator:
assert agent.verbose is False
assert agent.llm.model == "gpt-4o-mini"
def test_evaluator_with_custom_llm(self, crew_planner):
custom_llm = LLM(model="gpt-4")
evaluator = CrewEvaluator(crew_planner.crew, custom_llm)
agent = evaluator._evaluator_agent()
assert agent.llm == custom_llm
def test_evaluator_with_string_llm(self, crew_planner):
evaluator = CrewEvaluator(crew_planner.crew, "gpt-4")
agent = evaluator._evaluator_agent()
assert isinstance(agent.llm, LLM)
assert agent.llm.model == "gpt-4"
def test_evaluation_task(self, crew_planner):
evaluator_agent = Agent(
role="Evaluator Agent",