Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

Add version check to crew_chat.py (#1966)

devin-ai-integration[bot]67bf4aea56a4
diff --git a/src/crewai/cli/crew_chat.py b/src/crewai/cli/crew_chat.py
index a38315620..f1695f0a4 100644
--- a/src/crewai/cli/crew_chat.py
+++ b/src/crewai/cli/crew_chat.py
@@ -6,12 +6,42 @@ from typing import Any, Dict, List, Optional, Set, Tuple
import click
import tomli
+from packaging import version
+from crewai.cli.utils import read_toml
+from crewai.cli.version import get_crewai_version
from crewai.crew import Crew
from crewai.llm import LLM
from crewai.types.crew_chat import ChatInputField, ChatInputs
from crewai.utilities.llm_utils import create_llm
+MIN_REQUIRED_VERSION = "0.98.0"
+
+
+def check_conversational_crews_version(crewai_version: str, pyproject_data: dict) -> bool:
+ """
+ Check if the installed crewAI version supports conversational crews.
+
+ Args:
+ crewai_version: The current version of crewAI
+ pyproject_data: Dictionary containing pyproject.toml data
+
+ Returns:
+ bool: True if version check passes, False otherwise
+ """
+ try:
+ if version.parse(crewai_version) < version.parse(MIN_REQUIRED_VERSION):
+ click.secho(
+ "You are using an older version of crewAI that doesn't support conversational crews. "
+ "Run 'uv upgrade crewai' to get the latest version.",
+ fg="red"
+ )
+ return False
+ except version.InvalidVersion:
+ click.secho("Invalid crewAI version format detected", fg="red")
+ return False
+ return True
+
def run_chat():
"""
@@ -19,6 +49,11 @@ def run_chat():
Incorporates crew_name, crew_description, and input fields to build a tool schema.
Exits if crew_name or crew_description are missing.
"""
+ crewai_version = get_crewai_version()
+ pyproject_data = read_toml()
+
+ if not check_conversational_crews_version(crewai_version, pyproject_data):
+ return
crew, crew_name = load_crew_and_name()
chat_llm = initialize_chat_llm(crew)
if not chat_llm: