Skip to content

Commit aac34cf

Browse files
committed
feat: Adding support Multimodal embedders.
1 parent f3a9cf2 commit aac34cf

File tree

4 files changed

+52
-24
lines changed

4 files changed

+52
-24
lines changed

.code-samples.meilisearch.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,16 +769,21 @@ get_similar_post_1: |-
769769
client.index("INDEX_NAME").get_similar_documents({"id": "TARGET_DOCUMENT_ID", "embedder": "default"})
770770
search_parameter_reference_media_1: |-
771771
client.index('movies_fragments').search(
772-
"",
772+
"a futuristic space movie",
773773
{
774774
"media": {
775-
"image_url": "https://image.tmdb.org/t/p/w500/gEU2QniE6E77NI6lCU6MxlNBvIx.jpg"
775+
"textAndPoster": {
776+
"text": "a futuristic space movie",
777+
"image": {
778+
"mime": "image/jpeg",
779+
"data": "BASE64_ENCODED_IMAGE_DATA"
780+
}
781+
}
776782
},
777783
"hybrid": {
778-
"embedder": "voyage",
784+
"embedder": "multimodal",
779785
"semanticRatio": 1.0
780786
},
781-
"limit": 3
782787
}
783788
)
784789
webhooks_get_1: |-

meilisearch/client.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,22 +1111,40 @@ def _valid_uuid(uuid: str) -> bool:
11111111
match = uuid4hex.match(uuid)
11121112
return bool(match)
11131113

1114-
def get_experimental_features(self) -> dict:
1115-
"""
1116-
Retrieve the current settings for all experimental features.
1117-
Returns:
1118-
dict: A mapping of feature names to their enabled/disabled state.
1114+
def get_experimental_features(self) -> Dict[str, Any]:
1115+
"""Retrieve the current settings for all experimental features.
1116+
1117+
Returns
1118+
-------
1119+
features:
1120+
A dictionary mapping feature names to their enabled/disabled state.
1121+
For example: {"multimodal": True, "vectorStore": False}
1122+
1123+
Raises
1124+
------
1125+
MeilisearchApiError
1126+
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
11191127
"""
11201128
return self.http.get(self.config.paths.experimental_features)
11211129

1122-
def update_experimental_features(self, features: dict) -> dict:
1123-
"""
1124-
Update one or more experimental features.
1130+
def update_experimental_features(self, features: Dict[str, bool]) -> Dict[str, Any]:
1131+
"""Update one or more experimental features.
11251132
1126-
Args:
1127-
features (dict): A dictionary mapping feature names to booleans.
1128-
For example, {"multimodal": True} to enable multimodal.
1129-
Returns:
1130-
dict: The updated experimental features settings.
1133+
Parameters
1134+
----------
1135+
features:
1136+
A dictionary mapping feature names to booleans.
1137+
For example, {"multimodal": True} to enable multimodal,
1138+
or {"multimodal": True, "vectorStore": False} to update multiple features.
1139+
1140+
Returns
1141+
-------
1142+
features:
1143+
The updated experimental features settings as a dictionary.
1144+
1145+
Raises
1146+
------
1147+
MeilisearchApiError
1148+
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
11311149
"""
11321150
return self.http.patch(self.config.paths.experimental_features, body=features)

meilisearch/models/embedders.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ class RestEmbedder(CamelBase):
167167
Template defining the data Meilisearch sends to the embedder
168168
document_template_max_bytes: Optional[int]
169169
Maximum allowed size of rendered document template (defaults to 400)
170-
indexing_fragments: Optional[Dict[str, Dict[str, str]]]
171-
Defines how to fragment documents for indexing (multi-modal search)
172-
search_fragments: Optional[Dict[str, Dict[str, str]]]
173-
Defines how to fragment search queries (multi-modal search)
170+
indexing_fragments: Optional[Dict[str, Dict[str, Any]]]
171+
Defines how to fragment documents for indexing (multi-modal search).
172+
Fragments can contain complex nested structures (e.g., lists of objects).
173+
search_fragments: Optional[Dict[str, Dict[str, Any]]]
174+
Defines how to fragment search queries (multi-modal search).
175+
Fragments can contain complex nested structures (e.g., lists of objects).
174176
request: Dict[str, Any]
175177
A JSON value representing the request Meilisearch makes to the remote embedder
176178
response: Dict[str, Any]
@@ -189,8 +191,8 @@ class RestEmbedder(CamelBase):
189191
dimensions: Optional[int] = None
190192
document_template: Optional[str] = None
191193
document_template_max_bytes: Optional[int] = None
192-
indexing_fragments: Optional[Dict[str, Dict[str, str]]] = None
193-
search_fragments: Optional[Dict[str, Dict[str, str]]] = None
194+
indexing_fragments: Optional[Dict[str, Dict[str, Any]]] = None
195+
search_fragments: Optional[Dict[str, Dict[str, Any]]] = None
194196
request: Dict[str, Any]
195197
response: Dict[str, Any]
196198
headers: Optional[Dict[str, str]] = None

tests/client/test_experimental_features.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ def test_get_experimental_features(client):
55
"""Test getting experimental features."""
66
response = client.get_experimental_features()
77
assert isinstance(response, dict)
8+
# Check that at least one known experimental feature is present
89
assert "multimodal" in response or "vectorStoreSetting" in response
910

1011

@@ -23,7 +24,9 @@ def test_update_experimental_features(client):
2324

2425
def test_update_multiple_experimental_features(client):
2526
"""Test updating multiple experimental features at once."""
26-
response = client.update_experimental_features({"multimodal": True, "vectorStoreSetting": True})
27+
response = client.update_experimental_features(
28+
{"multimodal": True, "vectorStoreSetting": True}
29+
)
2730
assert isinstance(response, dict)
2831
# At least one should be accepted (depending on Meilisearch version)
2932
assert "multimodal" in response or "vectorStoreSetting" in response

0 commit comments

Comments
 (0)