-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add version check to crew_chat.py #1966
Merged
bhancockio
merged 6 commits into
main
from
devin/1737752919-add-version-check-crew-chat
Jan 24, 2025
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7c56148
Add version check to crew_chat.py with min version 0.98.0
devin-ai-integration[bot] 73939b9
Fix import sorting in crew_chat.py
devin-ai-integration[bot] 3c2b111
Fix import sorting in crew_chat.py (attempt 3)
devin-ai-integration[bot] 8f167b1
Update error message, add version check helper, fix import sorting
devin-ai-integration[bot] 930f701
Fix import sorting with Ruff auto-fix
devin-ai-integration[bot] 1276683
Remove poetry check and import comment headers in crew_chat.py
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,63 @@ | ||
# 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 | ||
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): | ||
if pyproject_data.get("tool", {}).get("poetry"): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this check right? We can get rid of this. |
||
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() | ||
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: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop unnecessary comments like this and the ones above.