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

chore!: Rename model_name to model in the Gradient integration #228

Merged
merged 4 commits into from
Jan 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GradientDocumentEmbedder:
embedder = GradientDocumentEmbedder(
access_token=gradient_access_token,
workspace_id=gradient_workspace_id,
model_name="bge_large"))
model="bge_large"))
p = Pipeline()
p.add_component(embedder, name="document_embedder")
p.add_component(instance=GradientDocumentEmbedder(
Expand All @@ -41,7 +41,7 @@ class GradientDocumentEmbedder:
def __init__(
self,
*,
model_name: str = "bge-large",
model: str = "bge-large",
batch_size: int = 32_768,
access_token: Optional[str] = None,
workspace_id: Optional[str] = None,
Expand All @@ -51,7 +51,7 @@ def __init__(
"""
Create a GradientDocumentEmbedder component.

:param model_name: The name of the model to use.
:param model: The name of the model to use.
:param batch_size: Update cycle for tqdm progress bar, default is to update every 32_768 docs.
:param access_token: The Gradient access token. If not provided it's read from the environment
variable GRADIENT_ACCESS_TOKEN.
Expand All @@ -62,7 +62,7 @@ def __init__(
"""
self._batch_size = batch_size
self._host = host
self._model_name = model_name
self._model_name = model
self._progress_bar = progress_bar

self._gradient = Gradient(access_token=access_token, host=host, workspace_id=workspace_id)
Expand All @@ -77,7 +77,7 @@ def to_dict(self) -> dict:
"""
Serialize the component to a Python dictionary.
"""
return default_to_dict(self, workspace_id=self._gradient.workspace_id, model_name=self._model_name)
return default_to_dict(self, workspace_id=self._gradient.workspace_id, model=self._model_name)

def warm_up(self) -> None:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GradientTextEmbedder:
embedder = GradientTextEmbedder(
access_token=gradient_access_token,
workspace_id=gradient_workspace_id,
model_name="bge_large")
model="bge_large")
p = Pipeline()
p.add_component(instance=embedder, name="text_embedder")
p.add_component(instance=InMemoryEmbeddingRetriever(document_store=InMemoryDocumentStore()), name="retriever")
Expand All @@ -25,23 +25,23 @@ class GradientTextEmbedder:
def __init__(
self,
*,
model_name: str = "bge-large",
model: str = "bge-large",
access_token: Optional[str] = None,
workspace_id: Optional[str] = None,
host: Optional[str] = None,
) -> None:
"""
Create a GradientTextEmbedder component.

:param model_name: The name of the model to use.
:param model: The name of the model to use.
:param access_token: The Gradient access token. If not provided it's read from the environment
variable GRADIENT_ACCESS_TOKEN.
:param workspace_id: The Gradient workspace ID. If not provided it's read from the environment
variable GRADIENT_WORKSPACE_ID.
:param host: The Gradient host. By default it uses https://api.gradient.ai/.
"""
self._host = host
self._model_name = model_name
self._model_name = model

self._gradient = Gradient(access_token=access_token, host=host, workspace_id=workspace_id)

Expand All @@ -55,7 +55,7 @@ def to_dict(self) -> dict:
"""
Serialize the component to a Python dictionary.
"""
return default_to_dict(self, workspace_id=self._gradient.workspace_id, model_name=self._model_name)
return default_to_dict(self, workspace_id=self._gradient.workspace_id, model=self._model_name)

def warm_up(self) -> None:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_to_dict(self):
data = component.to_dict()
assert data == {
"type": "gradient_haystack.embedders.gradient_document_embedder.GradientDocumentEmbedder",
"init_parameters": {"workspace_id": workspace_id, "model_name": "bge-large"},
"init_parameters": {"workspace_id": workspace_id, "model": "bge-large"},
}

@pytest.mark.unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_to_dict(self):
data = component.to_dict()
assert data == {
"type": "gradient_haystack.embedders.gradient_text_embedder.GradientTextEmbedder",
"init_parameters": {"workspace_id": workspace_id, "model_name": "bge-large"},
"init_parameters": {"workspace_id": workspace_id, "model": "bge-large"},
}

@pytest.mark.unit
Expand Down