Skip to content

Update embedders settings, hybrid search, and add tests for AI search methods #1087

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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
Fix missing imports
Strift committed Apr 2, 2025
commit e515f297cf883d55d01c9b07b702ee6b2a9704bf
27 changes: 20 additions & 7 deletions meilisearch/index.py
Original file line number Diff line number Diff line change
@@ -28,18 +28,17 @@
Embedders,
EmbedderType,
HuggingFaceEmbedder,
OllamaEmbedder,
OpenAiEmbedder,
RestEmbedder,
UserProvidedEmbedder,
)
from meilisearch.models.index import (
Faceting,
IndexStats,
LocalizedAttributes,
OllamaEmbedder,
OpenAiEmbedder,
Pagination,
ProximityPrecision,
RestEmbedder,
TypoTolerance,
)
from meilisearch.models.task import Task, TaskInfo, TaskResults
@@ -1924,7 +1923,6 @@ def get_embedders(self) -> Embedders | None:
if not response:
return None


embedders: dict[str, EmbedderType] = {}
for k, v in response.items():
source = v.get("source")
@@ -1968,9 +1966,24 @@ def update_embedders(self, body: Union[MutableMapping[str, Any], None]) -> TaskI
Meilisearch error codes are described here: https://www.meilisearch.com/docs/reference/errors/error_codes#meilisearch-errors
"""
if body is not None and body.get("embedders"):
for _, v in body["embedders"].items():
if "documentTemplateMaxBytes" in v and v["documentTemplateMaxBytes"] is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this handling done by Meili now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing it did not trigger any test failure but it might simply be untested, so I added it back to avoid any unwanted side effects

del v["documentTemplateMaxBytes"]
embedders: dict[str, EmbedderType] = {}
for k, v in body["embedders"].items():
source = v.get("source")
if source == "openAi":
embedders[k] = OpenAiEmbedder(**v)
elif source == "huggingFace":
embedders[k] = HuggingFaceEmbedder(**v)
elif source == "ollama":
embedders[k] = OllamaEmbedder(**v)
elif source == "rest":
embedders[k] = RestEmbedder(**v)
elif source == "userProvided":
embedders[k] = UserProvidedEmbedder(**v)
else:
# Default to UserProvidedEmbedder for unknown sources
embedders[k] = UserProvidedEmbedder(**v)

body = {"embedders": {k: v.model_dump(by_alias=True) for k, v in embedders.items()}}

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