From 837789e4a100baf4a3cd0720b4f7c7c549d23ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krassowski?= <5832902+krassowski@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:59:19 +0100 Subject: [PATCH] Fix streaming in `HuggingFaceHub` provider (#894) the overridden method is no longer overriding allowed task list since #784 but is only breaking streaming - it can be removed --- .../jupyter_ai_magics/providers.py | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py b/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py index e017125ba..0777ee6e2 100644 --- a/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py +++ b/packages/jupyter-ai-magics/jupyter_ai_magics/providers.py @@ -627,35 +627,6 @@ class HfHubProvider(BaseProvider, HuggingFaceEndpoint): auth_strategy = EnvAuthStrategy(name="HUGGINGFACEHUB_API_TOKEN") registry = True - # Override the parent's validate_environment with a custom list of valid tasks - @root_validator() - def validate_environment(cls, values: Dict) -> Dict: - """Validate that api key and python package exists in environment.""" - try: - huggingfacehub_api_token = get_from_dict_or_env( - values, "huggingfacehub_api_token", "HUGGINGFACEHUB_API_TOKEN" - ) - except Exception as e: - raise ValueError( - "Could not authenticate with huggingface_hub. " - "Please check your API token." - ) from e - try: - from huggingface_hub import InferenceClient - - values["client"] = InferenceClient( - model=values["model"], - timeout=values["timeout"], - token=huggingfacehub_api_token, - **values["server_kwargs"], - ) - except ImportError: - raise ValueError( - "Could not import huggingface_hub python package. " - "Please install it with `pip install huggingface_hub`." - ) - return values - # Handle text and image outputs def _call( self, prompt: str, stop: Optional[List[str]] = None, **kwargs: Any