Skip to content

Commit

Permalink
changes requested
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Apr 5, 2024
1 parent 14cedf4 commit e467feb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 5 additions & 7 deletions haystack/components/embedders/hugging_face_api_text_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
class HuggingFaceAPITextEmbedder:
"""
This component can be used to embed strings using different Hugging Face APIs:
- [free Serverless Inference API]((https://huggingface.co/inference-api)
- [paid Inference Endpoints](https://huggingface.co/inference-endpoints)
- [self-hosted Text Embeddings Inference](https://github.com/huggingface/text-embeddings-inference)
- [Free Serverless Inference API]((https://huggingface.co/inference-api)
- [Paid Inference Endpoints](https://huggingface.co/inference-endpoints)
- [Self-hosted Text Embeddings Inference](https://github.com/huggingface/text-embeddings-inference)
Example usage with the free Serverless Inference API:
Expand Down Expand Up @@ -65,8 +65,8 @@ class HuggingFaceAPITextEmbedder:

def __init__(
self,
api_type: Union[HFEmbeddingAPIType, str] = HFEmbeddingAPIType.SERVERLESS_INFERENCE_API,
api_params: Optional[Dict[str, str]] = None,
api_type: Union[HFEmbeddingAPIType, str],
api_params: Dict[str, str],
token: Optional[Secret] = Secret.from_env_var("HF_API_TOKEN", strict=False),
prefix: str = "",
suffix: str = "",
Expand Down Expand Up @@ -104,8 +104,6 @@ def __init__(
if isinstance(api_type, str):
api_type = HFEmbeddingAPIType.from_str(api_type)

api_params = api_params or {}

if api_type == HFEmbeddingAPIType.SERVERLESS_INFERENCE_API:
model = api_params.get("model")
if model is None:
Expand Down
5 changes: 5 additions & 0 deletions haystack/utils/hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ class HFEmbeddingAPIType(Enum):
API type to use for Hugging Face API Embedders.
"""

# HF [Text Embeddings Inference (TEI)](https://github.com/huggingface/text-embeddings-inference).
TEXT_EMBEDDINGS_INFERENCE = "text_embeddings_inference"

# HF [Inference Endpoints](https://huggingface.co/inference-endpoints).
INFERENCE_ENDPOINTS = "inference_endpoints"

# HF [Serverless Inference API](https://huggingface.co/inference-api).
SERVERLESS_INFERENCE_API = "serverless_inference_api"

def __str__(self):
Expand Down

0 comments on commit e467feb

Please sign in to comment.