Skip to content
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

fix/pip install messages #1095

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/distilabel/models/embeddings/llamacpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def load(self) -> None:
except ImportError as ie:
raise ImportError(
"`llama-cpp-python` package is not installed. Please install it using"
" `pip install llama-cpp-python`."
" `pip install 'distilabel[llama-cpp]'`."
) from ie

if self.repo_id is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/embeddings/sentence_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def load(self) -> None:
except ImportError as e:
raise ImportError(
"`sentence-transformers` package is not installed. Please install it using"
" `pip install sentence-transformers`."
" `pip install 'distilabel[sentence-transformers]'`."
) from e

self._model = SentenceTransformer(
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/embeddings/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def load(self) -> None:

except ImportError as ie:
raise ImportError(
"vLLM is not installed. Please install it using `pip install vllm`."
"vLLM is not installed. Please install it using `pip install 'distilabel[vllm]'`."
) from ie

self._model = _vLLM(
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/llms/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def load(self) -> None:
except ImportError as ie:
raise ImportError(
"Anthropic Python client is not installed. Please install it using"
" `pip install anthropic`."
" `pip install 'distilabel[anthropic]'`."
) from ie

if self.api_key is None:
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/llms/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def load(self) -> None:
except ImportError as ie:
raise ImportError(
"OpenAI Python client is not installed. Please install it using"
" `pip install openai`."
" `pip install 'distilabel[openai]'`."
) from ie

if self.api_key is None:
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/llms/groq.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def load(self) -> None:
except ImportError as ie:
raise ImportError(
"Groq Python client is not installed. Please install it using"
' `pip install groq` or from the extras as `pip install "distilabel[groq]"`.'
' `pip install "distilabel[groq]"`.'
) from ie

if self.api_key is None:
Expand Down
4 changes: 2 additions & 2 deletions src/distilabel/models/llms/huggingface/inference_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def load(self) -> None: # noqa: C901
except ImportError as ie:
raise ImportError(
"Hugging Face Hub Python client is not installed. Please install it using"
" `pip install huggingface-hub`."
" `pip install 'distilabel[hf-inference-endpoints]'`."
) from ie

if self.api_key is None:
Expand Down Expand Up @@ -311,7 +311,7 @@ def load(self) -> None: # noqa: C901
except ImportError as ie:
raise ImportError(
"Transformers Python client is not installed. Please install it using"
" `pip install transformers`."
" `pip install 'distilabel[hf-inference-endpoints]'`."
) from ie

self._tokenizer = AutoTokenizer.from_pretrained(self.tokenizer_id)
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/llms/huggingface/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def load(self) -> None:
from transformers import pipeline
except ImportError as ie:
raise ImportError(
"Transformers is not installed. Please install it using `pip install transformers`."
"Transformers is not installed. Please install it using `pip install 'distilabel[hf-transformers]'`."
) from ie

token = self.token.get_secret_value() if self.token is not None else self.token
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/llms/litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def load(self) -> None:
except ImportError as e:
raise ImportError(
"LiteLLM Python client is not installed. Please install it using"
" `pip install litellm`."
" `pip install 'distilabel[litellm]'`."
) from e
self._aclient = litellm.acompletion

Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/llms/mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def load(self) -> None:
except ImportError as ie:
raise ImportError(
"MistralAI Python client is not installed. Please install it using"
" `pip install mistralai`."
" `pip install 'distilabel[mistralai]'`."
) from ie

if self.api_key is None:
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/llms/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def load(self) -> None:
except ImportError as e:
raise ImportError(
"Ollama Python client is not installed. Please install it using"
" `pip install ollama`."
" `pip install 'distilabel[ollama]'`."
) from e

if self.tokenizer_id:
Expand Down
3 changes: 2 additions & 1 deletion src/distilabel/models/llms/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class OpenAILLM(AsyncLLM):
api_key: the API key to authenticate the requests to the OpenAI API. Defaults to
`None` which means that the value set for the environment variable `OPENAI_API_KEY`
will be used, or `None` if not set.
default_headers: the default headers to use for the OpenAI API requests.
max_retries: the maximum number of times to retry the request to the API before
failing. Defaults to `6`.
timeout: the maximum time in seconds to wait for a response from the API. Defaults
Expand Down Expand Up @@ -186,7 +187,7 @@ def load(self) -> None:
except ImportError as ie:
raise ImportError(
"OpenAI Python client is not installed. Please install it using"
" `pip install openai`."
" `pip install 'distilabel[openai]'`."
) from ie

if self.api_key is None:
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/models/llms/vertexai.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def load(self) -> None:
except ImportError as e:
raise ImportError(
"vertexai is not installed. Please install it using"
" `pip install google-cloud-aiplatform`."
" `pip install 'distilabel[vertexai]'`."
) from e

if _is_gemini_model(self.model):
Expand Down
6 changes: 3 additions & 3 deletions src/distilabel/models/llms/vllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def load(self) -> None:
from vllm import LLM as _vLLM
except ImportError as ie:
raise ImportError(
"vLLM is not installed. Please install it using `pip install vllm`."
"vLLM is not installed. Please install it using `pip install 'distilabel[vllm]'`."
) from ie

self._model = _vLLM(
Expand Down Expand Up @@ -585,7 +585,7 @@ def load(self) -> None:
except ImportError as ie:
raise ImportError(
"OpenAI Python client is not installed. Please install it using"
" `pip install openai`."
" `pip install 'distilabel[openai]'`."
) from ie

self._client = OpenAI(
Expand All @@ -602,7 +602,7 @@ def load(self) -> None:
except ImportError as ie:
raise ImportError(
"To use `ClientvLLM` you need to install `transformers`."
"Please install it using `pip install transformers`."
"Please install it using `pip install 'distilabel[hf-transformers]'`."
) from ie

self._tokenizer = AutoTokenizer.from_pretrained(
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/pipeline/ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def _init_ray(self) -> None:
import ray
except ImportError as ie:
raise ImportError(
"ray is not installed. Please install it using `pip install ray[default]`."
"ray is not installed. Please install it using `pip install 'distilabel[ray]'`."
) from ie

if self._ray_head_node_url:
Expand Down
3 changes: 1 addition & 2 deletions src/distilabel/steps/argilla/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def model_post_init(self, __context: Any) -> None:

if importlib.util.find_spec("argilla") is None:
raise ImportError(
"Argilla is not installed. Please install it using `pip install argilla"
" --upgrade`."
"Argilla is not installed. Please install it using `pip install 'distilabel[argilla]'`."
)

def _client_init(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/steps/clustering/dbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def load(self) -> None:
super().load()
if importlib.util.find_spec("sklearn") is None:
raise ImportError(
"`sklearn` package is not installed. Please install it using `pip install scikit-learn`."
"`sklearn` package is not installed. Please install it using `pip install 'distilabel[text-clustering]'`."
)
from sklearn.cluster import DBSCAN as _DBSCAN

Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/steps/clustering/umap.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def load(self) -> None:
super().load()
if importlib.util.find_spec("umap") is None:
raise ImportError(
"`umap` package is not installed. Please install it using `pip install umap-learn`."
"`umap` package is not installed. Please install it using `pip install 'distilabel[text-clustering]'`."
)
from umap import UMAP as _UMAP

Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/steps/embeddings/nearest_neighbour.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def load(self) -> None:
if importlib.util.find_spec("faiss") is None:
raise ImportError(
"`faiss` package is not installed. Please install it using `pip install"
" faiss-cpu` or `pip install faiss-gpu`."
" 'distilabel[faiss-cpu]' or 'distilabel[faiss-gpu]'`."
)

@property
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/steps/filtering/_datasketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, config, name) -> None:
except ImportError as e:
raise ImportError(
"`diskcache` is required for disk storage using `MinHashDedup`. "
"Please install it using `pip install diskcache`."
"Please install it using `pip install 'distilabel[minhash]'`."
) from e

# Start with a clean file on each pipeline
Expand Down
4 changes: 2 additions & 2 deletions src/distilabel/steps/filtering/minhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def load(self) -> None:
if not importlib.import_module("datasketch"):
raise ImportError(
"`datasketch` is needed to deduplicate with MinHash, but is not installed. "
"Please install it using `pip install datasketch`."
"Please install it using `pip install 'distilabel[minhash]'`."
)
from datasketch import MinHash

Expand All @@ -193,7 +193,7 @@ def load(self) -> None:
if not importlib.import_module("nltk"):
raise ImportError(
"`nltk` is needed to tokenize based on words, but is not installed. "
"Please install it using `pip install nltk`. Then run `nltk.download('punkt_tab')`."
"Please install it using `pip install 'distilabel[minhash]'`. Then run `nltk.download('punkt_tab')`."
)
self._tokenizer = tokenized_on_words
else:
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/steps/reward_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def load(self) -> None:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
except ImportError as e:
raise ImportError(
"`transformers` is not installed. Please install it using `pip install transformers`."
"`transformers` is not installed. Please install it using `pip install 'distilabel[hf-transformers]'`."
) from e

token = self.token.get_secret_value() if self.token is not None else self.token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def prepare_instructor(
"""
if not importlib.util.find_spec("instructor"):
raise ImportError(
"`instructor` is not installed. Please install it using `pip install instructor`."
"`instructor` is not installed. Please install it using `pip install 'distilabel[instructor]'`."
)
import instructor

Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/steps/tasks/structured_outputs/outlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def prepare_guided_output(
"""
if not importlib.util.find_spec("outlines"):
raise ImportError(
"Outlines is not installed. Please install it using `pip install outlines`."
"Outlines is not installed. Please install it using `pip install 'distilabel[outlines]'`."
)

json_processor, regex_processor = _get_logits_processor(framework)
Expand Down
2 changes: 1 addition & 1 deletion src/distilabel/steps/truncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def load(self):
if not importlib.util.find_spec("transformers"):
raise ImportError(
"`transformers` is needed to tokenize, but is not installed. "
"Please install it using `pip install transformers`."
"Please install it using `pip install 'distilabel[hf-transformers]'`."
)

from transformers import AutoTokenizer
Expand Down
1 change: 1 addition & 0 deletions tests/unit/models/llms/test_anyscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_serialization(self) -> None:
"model": self.model_id,
"generation_kwargs": {},
"max_retries": 6,
"default_headers": None,
"base_url": "https://api.endpoints.anyscale.com/v1",
"timeout": 120,
"structured_output": None,
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/models/llms/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_azure_openai_llm_env_vars(self) -> None:
"api_version": "preview",
"generation_kwargs": {},
"max_retries": 6,
"default_headers": None,
"base_url": "https://example-resource.azure.openai.com/",
"timeout": 120,
"structured_output": None,
Expand All @@ -95,6 +96,7 @@ def test_azure_openai_llm_env_vars(self) -> None:
"generation_kwargs": {},
"max_retries": 6,
"base_url": "https://example-resource.azure.openai.com/",
"default_headers": None,
"timeout": 120,
"structured_output": {
"schema": DummyUserDetail.model_json_schema(),
Expand Down
1 change: 1 addition & 0 deletions tests/unit/models/llms/test_together.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_serialization(self) -> None:
"model": self.model_id,
"generation_kwargs": {},
"max_retries": 6,
"default_headers": None,
"base_url": "https://api.together.xyz/v1",
"timeout": 120,
"structured_output": None,
Expand Down
Loading