Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 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
14 changes: 14 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,20 @@ get_batch_1: |-
client.get_batch(BATCH_UID)
get_similar_post_1: |-
client.index("INDEX_NAME").get_similar_documents({"id": "TARGET_DOCUMENT_ID", "embedder": "default"})
search_parameter_reference_media_1: |-
client.index('movies_fragments').search(
"",
{
"media": {
"image_url": "https://image.tmdb.org/t/p/w500/gEU2QniE6E77NI6lCU6MxlNBvIx.jpg"
},
"hybrid": {
"embedder": "voyage",
"semanticRatio": 1.0
},
"limit": 3
}
)
webhooks_get_1: |-
client.get_webhooks()
webhooks_get_single_1: |-
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# This value contains a list of modules to be mocked up.
autodoc_mock_imports = ["camel_converter"]

html_title = 'Meilisearch Python | Documentation'
html_title = "Meilisearch Python | Documentation"

# Add Fathom analytics script
html_js_files = [
("https://cdn.usefathom.com/script.js", { "data-site": "QNBPJXIV", "defer": "defer" })
("https://cdn.usefathom.com/script.js", {"data-site": "QNBPJXIV", "defer": "defer"})
]
20 changes: 20 additions & 0 deletions meilisearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,3 +1110,23 @@ def _valid_uuid(uuid: str) -> bool:
)
match = uuid4hex.match(uuid)
return bool(match)

def get_experimental_features(self) -> dict:
"""
Retrieve the current settings for all experimental features.
Returns:
dict: A mapping of feature names to their enabled/disabled state.
"""
return self.http.get(self.config.paths.experimental_features)

def update_experimental_features(self, features: dict) -> dict:
"""
Update one or more experimental features.

Args:
features (dict): A dictionary mapping feature names to booleans.
For example, {"multimodal": True} to enable multimodal.
Returns:
dict: The updated experimental features settings.
"""
return self.http.patch(self.config.paths.experimental_features, body=features)
1 change: 1 addition & 0 deletions meilisearch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Paths:
localized_attributes = "localized-attributes"
edit = "edit"
network = "network"
experimental_features = "experimental-features"
webhooks = "webhooks"

def __init__(
Expand Down
6 changes: 6 additions & 0 deletions meilisearch/models/embedders.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ class RestEmbedder(CamelBase):
Template defining the data Meilisearch sends to the embedder
document_template_max_bytes: Optional[int]
Maximum allowed size of rendered document template (defaults to 400)
indexing_fragments: Optional[Dict[str, Dict[str, str]]]
Defines how to fragment documents for indexing (multi-modal search)
search_fragments: Optional[Dict[str, Dict[str, str]]]
Defines how to fragment search queries (multi-modal search)
request: Dict[str, Any]
A JSON value representing the request Meilisearch makes to the remote embedder
response: Dict[str, Any]
Expand All @@ -185,6 +189,8 @@ class RestEmbedder(CamelBase):
dimensions: Optional[int] = None
document_template: Optional[str] = None
document_template_max_bytes: Optional[int] = None
indexing_fragments: Optional[Dict[str, Dict[str, str]]] = None
search_fragments: Optional[Dict[str, Dict[str, str]]] = None
Copy link
Contributor

Choose a reason for hiding this comment

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

The type definition Dict[str, Dict[str, str]] for indexing_fragments and search_fragments seems too restrictive.

These fragments often contain complex nested structures (like lists of objects) wrapped in a value key.

For example, a valid fragment configuration looks like this:

"textAndPoster": {
    "value": {
        "content": [
            {"type": "text", "text": "..."},
            {"type": "image_url", "image_url": "..."}
        ]
    }
}

Would the Optional[Dict[str, Dict[str, Any]]] type be more fitting?

request: Dict[str, Any]
response: Dict[str, Any]
headers: Optional[Dict[str, str]] = None
Expand Down
29 changes: 29 additions & 0 deletions tests/client/test_experimental_features.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Tests for experimental features API."""


def test_get_experimental_features(client):
"""Test getting experimental features."""
response = client.get_experimental_features()
assert isinstance(response, dict)
assert "multimodal" in response or "vectorStoreSetting" in response


def test_update_experimental_features(client):
"""Test updating experimental features."""
# Enable multimodal
response = client.update_experimental_features({"multimodal": True})
assert isinstance(response, dict)
assert response.get("multimodal") is True

# Disable multimodal
response = client.update_experimental_features({"multimodal": False})
assert isinstance(response, dict)
assert response.get("multimodal") is False


def test_update_multiple_experimental_features(client):
"""Test updating multiple experimental features at once."""
response = client.update_experimental_features({"multimodal": True, "vectorStoreSetting": True})
assert isinstance(response, dict)
# At least one should be accepted (depending on Meilisearch version)
assert "multimodal" in response or "vectorStoreSetting" in response