-
Notifications
You must be signed in to change notification settings - Fork 97
Enable multi modal #1167
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
base: main
Are you sure you want to change the base?
Enable multi modal #1167
Conversation
WalkthroughThis PR introduces experimental features management to the Meilisearch Python client. New client methods enable retrieving, updating, enabling, and disabling experimental features like multimodal search. Configuration paths are expanded, REST embedder model fields for indexing and search fragments are added, and comprehensive test coverage validates the new functionality. Changes
Sequence DiagramsequenceDiagram
participant Client
participant HTTP Utilities
participant Meilisearch API
Note over Client: Experimental Features Management
Client->>Client: get_experimental_features()
Client->>HTTP Utilities: GET /experimental-features
HTTP Utilities->>Meilisearch API: HTTP GET
Meilisearch API-->>HTTP Utilities: feature settings dict
HTTP Utilities-->>Client: return dict
Client->>Client: update_experimental_features({features})
Client->>HTTP Utilities: PATCH /experimental-features
HTTP Utilities->>Meilisearch API: HTTP PATCH
Meilisearch API-->>HTTP Utilities: updated features dict
HTTP Utilities-->>Client: return dict
Note over Client: Convenience methods delegate to update
Client->>Client: enable_multimodal()
Client->>Client: update_experimental_features({multimodal: true})
Client->>Client: disable_multimodal()
Client->>Client: update_experimental_features({multimodal: false})
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes The changes follow consistent, repetitive patterns with mostly additive modifications:
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
meilisearch/client.py (4)
1000-1002: Enhance docstring to match established patterns.The new methods should follow the comprehensive docstring format used throughout this file, including Parameters, Returns, and Raises sections. This improves maintainability and API documentation consistency.
Apply this diff to improve the docstring and type hint:
- def get_experimental_features(self) -> dict: - """Get current experimental features settings.""" + def get_experimental_features(self) -> Dict[str, Any]: + """Get current experimental features settings. + + Returns + ------- + features: + Dictionary containing the current experimental features configuration. + + Raises + ------ + 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 + """ return self.http.get(self.config.paths.experimental_features)
1004-1006: Enhance docstring and add parameter type hint.The method should include a type hint for the
featuresparameter and follow the comprehensive docstring format used throughout this file.Apply this diff:
- def update_experimental_features(self, features: dict) -> dict: - """Update experimental features settings.""" + def update_experimental_features(self, features: Mapping[str, Any]) -> Dict[str, Any]: + """Update experimental features settings. + + Parameters + ---------- + features: + Dictionary containing experimental features to enable or disable (ex: {"multimodal": True}). + + Returns + ------- + features: + Dictionary containing the updated experimental features configuration. + + Raises + ------ + 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 + """ return self.http.patch(self.config.paths.experimental_features, body=features)
1008-1010: Enhance docstring to match established patterns.The convenience method should include comprehensive documentation following the file's conventions.
Apply this diff:
- def enable_multimodal(self) -> dict: - """Enable multimodal experimental feature.""" + def enable_multimodal(self) -> Dict[str, Any]: + """Enable the multimodal experimental feature. + + Returns + ------- + features: + Dictionary containing the updated experimental features configuration. + + Raises + ------ + 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 + """ return self.update_experimental_features({"multimodal": True})
1012-1014: Enhance docstring to match established patterns.The convenience method should include comprehensive documentation following the file's conventions.
Apply this diff:
- def disable_multimodal(self) -> dict: - """Disable multimodal experimental feature.""" + def disable_multimodal(self) -> Dict[str, Any]: + """Disable the multimodal experimental feature. + + Returns + ------- + features: + Dictionary containing the updated experimental features configuration. + + Raises + ------ + 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 + """ return self.update_experimental_features({"multimodal": False})tests/client/test_experimental_features.py (1)
4-55: Consider adding test cleanup and error handling tests.The tests modify global experimental features state but don't restore the original configuration afterward. This could affect other tests. Additionally, error handling paths are not covered.
Consider these improvements:
- Add cleanup to restore original state:
import pytest @pytest.fixture def cleanup_experimental_features(client): """Fixture to restore experimental features after test.""" original_features = client.get_experimental_features() yield client.update_experimental_features(original_features) def test_enable_multimodal(client, cleanup_experimental_features): """Test enabling multimodal experimental feature.""" response = client.enable_multimodal() assert isinstance(response, dict) assert response.get("multimodal") is True # Verify it's enabled features = client.get_experimental_features() assert features.get("multimodal") is True
- Add error handling tests:
def test_update_experimental_features_with_invalid_feature(client): """Test updating with an invalid feature name.""" # This behavior depends on the Meilisearch API - it may ignore unknown keys # or return an error. Verify the expected behavior. response = client.update_experimental_features({"invalid_feature": True}) assert isinstance(response, dict)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.code-samples.meilisearch.yaml(1 hunks)meilisearch/client.py(1 hunks)meilisearch/config.py(1 hunks)meilisearch/models/embedders.py(2 hunks)tests/client/test_experimental_features.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/client/test_experimental_features.py (3)
tests/conftest.py (1)
client(15-16)meilisearch/client.py (4)
get_experimental_features(1000-1002)update_experimental_features(1004-1006)enable_multimodal(1008-1010)disable_multimodal(1012-1014)meilisearch/_httprequests.py (1)
get(95-96)
meilisearch/client.py (1)
meilisearch/_httprequests.py (2)
get(95-96)patch(110-118)
🔇 Additional comments (3)
.code-samples.meilisearch.yaml (1)
766-779: Code sample effectively demonstrates multimodal search.The new
search_parameter_reference_media_1example correctly illustrates hybrid search with media parameters. The syntax is accurate, formatting is consistent with surrounding examples, and the parameter combination (empty query with media and hybrid settings) properly showcases this feature.Minor observations:
- The embedder name
"voyage"assumes it's a configured embedder; if not documented elsewhere, a clarifying comment could help users unfamiliar with available embedders.- The example is otherwise clear and complete.
meilisearch/config.py (1)
50-50: LGTM!The new path constant follows the established pattern and naming convention consistently with other paths in the class.
meilisearch/models/embedders.py (1)
170-173: LGTM!The new optional fields for multi-modal search are well-documented and appropriately typed. Using
Noneas the default value maintains backward compatibility while extending the RestEmbedder API for fragment configuration.Also applies to: 192-193
Add support for multi-modal search
#1134
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.