Skip to content

Commit 4036306

Browse files
meili-bors[bot]meili-botdureuillsanders41curquiza
authored
Merge #1018
1018: Changes related to the next Meilisearch release (v1.11.0) r=brunoocasali a=meili-bot Related to this issue: meilisearch/integration-guides#303 This PR: - gathers the changes related to the next Meilisearch release (v1.11.0) so that this package is ready when the official release is out. - should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases). - might eventually contain test failures until the Meilisearch v1.11.0 is out. ⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.11.0) is out. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._ Co-authored-by: meili-bot <[email protected]> Co-authored-by: Louis Dureuil <[email protected]> Co-authored-by: Paul Sanders <[email protected]> Co-authored-by: Clémentine <[email protected]>
2 parents 7edda62 + 9f811c8 commit 4036306

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

meilisearch/index.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ def get_settings(self) -> Dict[str, Any]:
955955

956956
return settings
957957

958-
def update_settings(self, body: Mapping[str, Any]) -> TaskInfo:
958+
def update_settings(self, body: MutableMapping[str, Any]) -> TaskInfo:
959959
"""Update settings of the index.
960960
961961
https://www.meilisearch.com/docs/reference/api/settings#update-settings
@@ -978,6 +978,11 @@ def update_settings(self, body: Mapping[str, Any]) -> TaskInfo:
978978
MeilisearchApiError
979979
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
980980
"""
981+
if body.get("embedders"):
982+
for _, v in body["embedders"].items():
983+
if "documentTemplateMaxBytes" in v and v["documentTemplateMaxBytes"] is None:
984+
del v["documentTemplateMaxBytes"]
985+
981986
task = self.http.patch(
982987
f"{self.config.paths.index}/{self.uid}/{self.config.paths.setting}", body
983988
)
@@ -1867,7 +1872,6 @@ def get_embedders(self) -> Embedders | None:
18671872

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

18781882
return Embedders(embedders=embedders)
18791883

1880-
def update_embedders(self, body: Union[Mapping[str, Any], None]) -> TaskInfo:
1884+
def update_embedders(self, body: Union[MutableMapping[str, Any], None]) -> TaskInfo:
18811885
"""Update embedders of the index.
18821886
18831887
Parameters
@@ -1896,6 +1900,12 @@ def update_embedders(self, body: Union[Mapping[str, Any], None]) -> TaskInfo:
18961900
MeilisearchApiError
18971901
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
18981902
"""
1903+
1904+
if body:
1905+
for _, v in body.items():
1906+
if "documentTemplateMaxBytes" in v and v["documentTemplateMaxBytes"] is None:
1907+
del v["documentTemplateMaxBytes"]
1908+
18991909
task = self.http.patch(self.__settings_url_for(self.config.paths.embedders), body)
19001910

19011911
return TaskInfo(**task)

meilisearch/models/index.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,19 @@ class ProximityPrecision(str, Enum):
5656

5757
class OpenAiEmbedder(CamelBase):
5858
source: str = "openAi"
59-
model: Optional[str] = None # Defaults to text-embedding-ada-002
59+
model: Optional[str] = None # Defaults to text-embedding-3-small
6060
dimensions: Optional[int] = None # Uses the model default
6161
api_key: Optional[str] = None # Can be provided through a CLI option or environment variable
6262
document_template: Optional[str] = None
63+
document_template_max_bytes: Optional[int] = None # Default to 400
6364

6465

6566
class HuggingFaceEmbedder(CamelBase):
6667
source: str = "huggingFace"
6768
model: Optional[str] = None # Defaults to BAAI/bge-base-en-v1.5
6869
revision: Optional[str] = None
6970
document_template: Optional[str] = None
71+
document_template_max_bytes: Optional[int] = None # Default to 400
7072

7173

7274
class UserProvidedEmbedder(CamelBase):

tests/index/test_index_search_meilisearch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ def test_show_ranking_score(index_with_documents):
505505
@pytest.mark.usefixtures("enable_vector_search")
506506
def test_vector_search(index_with_documents_and_vectors):
507507
response = index_with_documents_and_vectors().search(
508-
"", opt_params={"vector": [0.1, 0.2], "hybrid": {"semanticRatio": 1.0}}
508+
"",
509+
opt_params={"vector": [0.1, 0.2], "hybrid": {"semanticRatio": 1.0, "embedder": "default"}},
509510
)
510511
assert len(response["hits"]) > 0
511512

0 commit comments

Comments
 (0)