Skip to content

Commit

Permalink
chore: remove deprecated TGI generators (#7908)
Browse files Browse the repository at this point in the history
* remove deprecated TGI generators

* rm unused import
  • Loading branch information
anakin87 committed Jun 21, 2024
1 parent d158be4 commit c59ad95
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 1,342 deletions.
2 changes: 0 additions & 2 deletions docs/pydoc/config/generators_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ loaders:
[
"azure",
"hugging_face_local",
"hugging_face_tgi",
"hugging_face_api",
"openai",
"chat/azure",
"chat/hugging_face_local",
"chat/hugging_face_tgi",
"chat/hugging_face_api",
"chat/openai",
]
Expand Down
9 changes: 1 addition & 8 deletions haystack/components/generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
)
from haystack.components.generators.azure import AzureOpenAIGenerator
from haystack.components.generators.hugging_face_local import HuggingFaceLocalGenerator
from haystack.components.generators.hugging_face_tgi import HuggingFaceTGIGenerator
from haystack.components.generators.hugging_face_api import HuggingFaceAPIGenerator

__all__ = [
"HuggingFaceLocalGenerator",
"HuggingFaceTGIGenerator",
"HuggingFaceAPIGenerator",
"OpenAIGenerator",
"AzureOpenAIGenerator",
]
__all__ = ["HuggingFaceLocalGenerator", "HuggingFaceAPIGenerator", "OpenAIGenerator", "AzureOpenAIGenerator"]
2 changes: 0 additions & 2 deletions haystack/components/generators/chat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
)
from haystack.components.generators.chat.azure import AzureOpenAIChatGenerator
from haystack.components.generators.chat.hugging_face_local import HuggingFaceLocalChatGenerator
from haystack.components.generators.chat.hugging_face_tgi import HuggingFaceTGIChatGenerator
from haystack.components.generators.chat.hugging_face_api import HuggingFaceAPIChatGenerator

__all__ = [
"HuggingFaceLocalChatGenerator",
"HuggingFaceTGIChatGenerator",
"HuggingFaceAPIChatGenerator",
"OpenAIChatGenerator",
"AzureOpenAIChatGenerator",
Expand Down
332 changes: 0 additions & 332 deletions haystack/components/generators/chat/hugging_face_tgi.py

This file was deleted.

293 changes: 0 additions & 293 deletions haystack/components/generators/hugging_face_tgi.py

This file was deleted.

23 changes: 0 additions & 23 deletions haystack/utils/hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from enum import Enum
from typing import Any, Callable, Dict, List, Optional, Union

import requests

from haystack import logging
from haystack.dataclasses import StreamingChunk
from haystack.lazy_imports import LazyImport
Expand Down Expand Up @@ -212,27 +210,6 @@ def resolve_hf_pipeline_kwargs(
return huggingface_pipeline_kwargs


def list_inference_deployed_models(headers: Optional[Dict] = None) -> List[str]:
"""
List all currently deployed models on HF TGI free tier
:param headers: Optional dictionary of headers to include in the request
:return: list of all currently deployed models
:raises Exception: If the request to the TGI API fails
"""
resp = requests.get(
"https://api-inference.huggingface.co/framework/text-generation-inference", headers=headers, timeout=10
)

payload = resp.json()
if resp.status_code != 200:
message = payload.get("error", "Unknown TGI error")
error_type = payload.get("error_type", "Unknown TGI error type")
raise Exception(f"Failed to fetch TGI deployed models: {message}. Error type: {error_type}")
return [model["model_id"] for model in payload]


def check_valid_model(model_id: str, model_type: HFModelType, token: Optional[Secret]) -> None:
"""
Check if the provided model ID corresponds to a valid model on HuggingFace Hub.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
upgrade:
- |
Deprecated `HuggingFaceTGIGenerator` and `HuggingFaceTGIChatGenerator` have been removed.
Use `HuggingFaceAPIGenerator` and `HuggingFaceAPIChatGenerator` instead.
Loading

0 comments on commit c59ad95

Please sign in to comment.