mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-01 13:18:10 +00:00
fix: prevent date-stamped model names from false no-prefill detection
The regex now limits the minor version capture to 1-2 digits so names like claude-opus-4-20250514 are not misclassified as 4.20250514. Added tests for date-stamped and Bedrock-style model IDs. Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -2295,7 +2295,7 @@ class LLM(BaseLLM):
|
||||
# Fallback heuristic for model names not in the litellm registry
|
||||
model_lower = (self.model or "").lower()
|
||||
if "claude" in model_lower:
|
||||
match = re.search(r"claude.*?(\d+)[.-](\d+)", model_lower)
|
||||
match = re.search(r"claude.*?(\d+)[.-](\d{1,2})(?!\d)", model_lower)
|
||||
if match:
|
||||
major, minor = int(match.group(1)), int(match.group(2))
|
||||
if (major == 4 and minor >= 6) or major >= 5:
|
||||
|
||||
@@ -1838,7 +1838,7 @@ class AnthropicCompletion(BaseLLM):
|
||||
assistant prefill.
|
||||
"""
|
||||
model_lower = self.model.lower()
|
||||
match = re.search(r"claude.*?(\d+)[.-](\d+)", model_lower)
|
||||
match = re.search(r"claude.*?(\d+)[.-](\d{1,2})(?!\d)", model_lower)
|
||||
if match:
|
||||
major, minor = int(match.group(1)), int(match.group(2))
|
||||
if (major == 4 and minor >= 6) or major >= 5:
|
||||
|
||||
@@ -73,6 +73,17 @@ class TestAnthropicPrefillDetection:
|
||||
llm = self._make_anthropic_llm("claude-5-0-opus")
|
||||
assert llm.supports_assistant_prefill() is False
|
||||
|
||||
def test_date_stamped_claude_4_not_falsely_flagged(self):
|
||||
"""claude-opus-4-20250514 should NOT be treated as 4.20250514."""
|
||||
llm = self._make_anthropic_llm("claude-opus-4-20250514")
|
||||
assert llm.supports_assistant_prefill() is True
|
||||
|
||||
def test_bedrock_date_stamped_model(self):
|
||||
"""Bedrock-style IDs like claude-opus-4-20250514-v1:0 must not
|
||||
be misclassified."""
|
||||
llm = self._make_anthropic_llm("claude-opus-4-20250514-v1:0")
|
||||
assert llm.supports_assistant_prefill() is True
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# AnthropicCompletion temperature dropping
|
||||
|
||||
Reference in New Issue
Block a user