Skip to content

Commit

Permalink
Update error message, add version check helper, fix import sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
1 parent 3c2b111 commit 8f167b1
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions src/crewai/cli/crew_chat.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Standard library
import json
import re
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Tuple

# Third-party
import click
import tomli
from packaging import version

# Local
from crewai.cli.utils import read_toml
from crewai.cli.version import get_crewai_version
from crewai.crew import Crew
Expand All @@ -16,25 +19,45 @@
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):
if pyproject_data.get("tool", {}).get("poetry"):
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():
"""
Runs an interactive chat loop using the Crew's chat LLM with function calling.
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()
min_required_version = "0.98.0"

pyproject_data = read_toml()

if pyproject_data.get("tool", {}).get("poetry") and (
version.parse(crewai_version) < version.parse(min_required_version)
):
click.secho(
f"You are running an older version of crewAI ({crewai_version}) that uses poetry pyproject.toml. "
f"Please run `crewai update` to update your pyproject.toml to use uv.",
fg="red",
)
if not check_conversational_crews_version(crewai_version, pyproject_data):
return
crew, crew_name = load_crew_and_name()
chat_llm = initialize_chat_llm(crew)
Expand Down

0 comments on commit 8f167b1

Please sign in to comment.