Skip to content

Commit

Permalink
feat: Adding timeout to nomic embed
Browse files Browse the repository at this point in the history
  • Loading branch information
tazarov committed Jan 16, 2025
1 parent 65c95da commit 8a82369
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion chromadbx/embeddings/nomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(
max_tokens_per_text: Optional[int] = 8192,
long_text_mode: Optional[LongTextMode] = LongTextMode.TRUNCATE,
task_type: Optional[TaskType] = TaskType.SEARCH_DOCUMENT,
timeout: Optional[float] = 60.0,
) -> None:
"""
Initialize the Nomic Embedding Function.
Expand All @@ -44,6 +45,7 @@ def __init__(
max_tokens_per_text (int): The maximum number of tokens per text. E.g. 8192 for "nomic-embed-text-v1.5".
long_text_mode (str): The mode to use for long texts. E.g. "truncate" or "mean".
task_type (str): The task type to use for the Nomic Embedding API. E.g. "search_document", "search_query", "classification", and "clustering".
timeout (float): The timeout for the Nomic Embedding API. E.g. 60.0 for 60 seconds.
"""
try:
import httpx
Expand All @@ -65,7 +67,7 @@ def __init__(
self._dimensionality = dimensionality
self._long_text_mode = long_text_mode
self._max_tokens_per_text = max_tokens_per_text
self._client = httpx.Client()
self._client = httpx.Client(timeout=timeout)
self._client.headers.update(
{
"Content-Type": "application/json",
Expand Down

0 comments on commit 8a82369

Please sign in to comment.