mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-04 16:52:37 +00:00
feat: improve LLM validation and error handling
- Add descriptive error messages with usage context - Add LLM instance validation - Add deprecation warning for openai_model_name - Add string representation to CrewEvaluator - Add edge case tests Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -38,10 +38,18 @@ class CrewEvaluator:
|
||||
|
||||
def __init__(self, crew, llm: Union[str, LLM]):
|
||||
self.crew = crew
|
||||
self.llm = llm if isinstance(llm, LLM) else LLM(model=llm)
|
||||
try:
|
||||
self.llm = llm if isinstance(llm, LLM) else LLM(model=llm)
|
||||
if not hasattr(self.llm, 'model'):
|
||||
raise ValueError("Provided LLM instance must have a 'model' attribute")
|
||||
except Exception as e:
|
||||
raise ValueError(f"Failed to initialize LLM: {str(e)}")
|
||||
self._telemetry = Telemetry()
|
||||
self._setup_for_evaluating()
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"CrewEvaluator(model={str(self.llm)}, iteration={self.iteration})"
|
||||
|
||||
def _setup_for_evaluating(self) -> None:
|
||||
"""Sets up the crew for evaluating."""
|
||||
for task in self.crew.tasks:
|
||||
|
||||
Reference in New Issue
Block a user