From ffb8bedf1bc26ee414ed99b215120c469684e4b7 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:55:31 +0000 Subject: [PATCH] Fix #2551: Add Huggingface to provider list in CLI Co-Authored-By: Joe Moura --- src/crewai/cli/constants.py | 17 +++++++++++++++++ tests/cli/test_constants.py | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/cli/test_constants.py diff --git a/src/crewai/cli/constants.py b/src/crewai/cli/constants.py index 13279f8d3..0c698ec2c 100644 --- a/src/crewai/cli/constants.py +++ b/src/crewai/cli/constants.py @@ -85,6 +85,16 @@ ENV_VARS = { "key_name": "CEREBRAS_API_KEY", }, ], + "huggingface": [ + { + "prompt": "Enter your HUGGINGFACE API key (press Enter to skip)", + "key_name": "HUGGINGFACE_API_KEY", + }, + { + "prompt": "Enter your Huggingface API base URL (press Enter to skip)", + "key_name": "base_url", + }, + ], } @@ -93,6 +103,7 @@ PROVIDERS = [ "anthropic", "gemini", "groq", + "huggingface", "ollama", "watson", "bedrock", @@ -156,6 +167,12 @@ MODELS = { "bedrock/mistral.mistral-7b-instruct-v0:2", "bedrock/mistral.mixtral-8x7b-instruct-v0:1", ], + "huggingface": [ + "huggingface/meta-llama/Meta-Llama-3.1-8B-Instruct", + "huggingface/mistralai/Mixtral-8x7B-Instruct-v0.1", + "huggingface/tiiuae/falcon-180B-chat", + "huggingface/google/gemma-7b-it", + ], } JSON_URL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json" diff --git a/tests/cli/test_constants.py b/tests/cli/test_constants.py new file mode 100644 index 000000000..9fa9b4c40 --- /dev/null +++ b/tests/cli/test_constants.py @@ -0,0 +1,22 @@ +import pytest +from crewai.cli.constants import PROVIDERS, ENV_VARS, MODELS + + +def test_huggingface_in_providers(): + """Test that Huggingface is in the PROVIDERS list.""" + assert "huggingface" in PROVIDERS + + +def test_huggingface_env_vars(): + """Test that Huggingface environment variables are properly configured.""" + assert "huggingface" in ENV_VARS + assert any( + detail.get("key_name") == "HUGGINGFACE_API_KEY" + for detail in ENV_VARS["huggingface"] + ) + + +def test_huggingface_models(): + """Test that Huggingface models are properly configured.""" + assert "huggingface" in MODELS + assert len(MODELS["huggingface"]) > 0