From e8d61d32db8a488d3a983c25b6224ee16b77443d Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:57:48 +0000 Subject: [PATCH] Fix test failures by updating model ID validation logic Co-Authored-By: Joe Moura --- src/crewai/llm.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/crewai/llm.py b/src/crewai/llm.py index c23df15dc..df6ca9d49 100644 --- a/src/crewai/llm.py +++ b/src/crewai/llm.py @@ -149,14 +149,11 @@ class LLM: callbacks: List[Any] = [], **kwargs, ): - # Validate model ID to ensure it's not empty, whitespace, or a numeric value without a provider prefix - if not model or (isinstance(model, str) and model.strip() == ""): - raise ValueError( - f"Invalid model ID: '{model}'. Model ID cannot be empty or whitespace. " - "Please specify a valid model ID with a provider prefix, e.g., 'openai/gpt-4'." - ) - - if isinstance(model, (int, float)) or (isinstance(model, str) and model.isdigit()): + # Only validate model ID if it's not None and is a numeric value without a provider prefix + if model is not None and ( + isinstance(model, (int, float)) or + (isinstance(model, str) and model.strip() and model.strip().isdigit()) + ): raise ValueError( f"Invalid model ID: {model}. Model ID cannot be a numeric value without a provider prefix. " "Please specify a valid model ID with a provider prefix, e.g., 'openai/gpt-4'."