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

Changes related to the next Meilisearch release (v1.11.0) #1018

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make backward compatible with Meilisearch < v1.11.0
  • Loading branch information
sanders41 committed Sep 30, 2024
commit b3d9b3cce630aace49ed8db444c8baca325f8f48
16 changes: 13 additions & 3 deletions meilisearch/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ def get_settings(self) -> Dict[str, Any]:

return settings

def update_settings(self, body: Mapping[str, Any]) -> TaskInfo:
def update_settings(self, body: MutableMapping[str, Any]) -> TaskInfo:
"""Update settings of the index.

https://www.meilisearch.com/docs/reference/api/settings#update-settings
Expand All @@ -978,6 +978,11 @@ def update_settings(self, body: Mapping[str, Any]) -> TaskInfo:
MeilisearchApiError
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors
"""
if body.get("embedders"):
for _, v in body["embedders"].items():
if "documentTemplateMaxBytes" in v and v["documentTemplateMaxBytes"] is None:
del v["documentTemplateMaxBytes"]

task = self.http.patch(
f"{self.config.paths.index}/{self.uid}/{self.config.paths.setting}", body
)
Expand Down Expand Up @@ -1867,7 +1872,6 @@ def get_embedders(self) -> Embedders | None:

embedders: dict[str, OpenAiEmbedder | HuggingFaceEmbedder | UserProvidedEmbedder] = {}
for k, v in response.items():
print(v.get("source"))
if v.get("source") == "openAi":
embedders[k] = OpenAiEmbedder(**v)
elif v.get("source") == "huggingFace":
Expand All @@ -1877,7 +1881,7 @@ def get_embedders(self) -> Embedders | None:

return Embedders(embedders=embedders)

def update_embedders(self, body: Union[Mapping[str, Any], None]) -> TaskInfo:
def update_embedders(self, body: Union[MutableMapping[str, Any], None]) -> TaskInfo:
"""Update embedders of the index.

Parameters
Expand All @@ -1896,6 +1900,12 @@ def update_embedders(self, body: Union[Mapping[str, Any], None]) -> TaskInfo:
MeilisearchApiError
An error containing details about why Meilisearch can't process your request. Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors
"""

if body:
for _, v in body.items():
if "documentTemplateMaxBytes" in v and v["documentTemplateMaxBytes"] is None:
del v["documentTemplateMaxBytes"]

task = self.http.patch(self.__settings_url_for(self.config.paths.embedders), body)

return TaskInfo(**task)
Expand Down