|
10 | 10 | from meilisearch.config import Config |
11 | 11 | from meilisearch.errors import version_error_hint_message |
12 | 12 | from meilisearch.models.document import Document, DocumentsResults |
13 | | -from meilisearch.models.index import Faceting, IndexStats, Pagination, TypoTolerance |
| 13 | +from meilisearch.models.index import Embedders, Faceting, IndexStats, Pagination, TypoTolerance |
14 | 14 | from meilisearch.models.task import Task, TaskInfo, TaskResults |
15 | 15 | from meilisearch.task import TaskHandler |
16 | 16 |
|
@@ -1757,6 +1757,71 @@ def reset_non_separator_tokens(self) -> TaskInfo: |
1757 | 1757 |
|
1758 | 1758 | return TaskInfo(**task) |
1759 | 1759 |
|
| 1760 | + # EMBEDDERS SUB-ROUTES |
| 1761 | + |
| 1762 | + def get_embedders(self) -> Embedders | None: |
| 1763 | + """Get embedders of the index. |
| 1764 | +
|
| 1765 | + Returns |
| 1766 | + ------- |
| 1767 | + settings: |
| 1768 | + The embedders settings of the index. |
| 1769 | +
|
| 1770 | + Raises |
| 1771 | + ------ |
| 1772 | + MeilisearchApiError |
| 1773 | + 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 |
| 1774 | + """ |
| 1775 | + response = self.http.get(self.__settings_url_for(self.config.paths.embedders)) |
| 1776 | + |
| 1777 | + if not response: |
| 1778 | + return None |
| 1779 | + |
| 1780 | + return Embedders(embedders=response) |
| 1781 | + |
| 1782 | + def update_embedders(self, body: Union[Mapping[str, Any], None]) -> TaskInfo: |
| 1783 | + """Update embedders of the index. |
| 1784 | +
|
| 1785 | + Parameters |
| 1786 | + ---------- |
| 1787 | + body: dict |
| 1788 | + Dictionary containing the embedders. |
| 1789 | +
|
| 1790 | + Returns |
| 1791 | + ------- |
| 1792 | + task_info: |
| 1793 | + TaskInfo instance containing information about a task to track the progress of an asynchronous process. |
| 1794 | + https://www.meilisearch.com/docs/reference/api/tasks#get-one-task |
| 1795 | +
|
| 1796 | + Raises |
| 1797 | + ------ |
| 1798 | + MeilisearchApiError |
| 1799 | + 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 |
| 1800 | + """ |
| 1801 | + task = self.http.patch(self.__settings_url_for(self.config.paths.embedders), body) |
| 1802 | + |
| 1803 | + return TaskInfo(**task) |
| 1804 | + |
| 1805 | + def reset_embedders(self) -> TaskInfo: |
| 1806 | + """Reset embedders of the index to default values. |
| 1807 | +
|
| 1808 | + Returns |
| 1809 | + ------- |
| 1810 | + task_info: |
| 1811 | + TaskInfo instance containing information about a task to track the progress of an asynchronous process. |
| 1812 | + https://www.meilisearch.com/docs/reference/api/tasks#get-one-task |
| 1813 | +
|
| 1814 | + Raises |
| 1815 | + ------ |
| 1816 | + MeilisearchApiError |
| 1817 | + 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 |
| 1818 | + """ |
| 1819 | + task = self.http.delete( |
| 1820 | + self.__settings_url_for(self.config.paths.embedders), |
| 1821 | + ) |
| 1822 | + |
| 1823 | + return TaskInfo(**task) |
| 1824 | + |
1760 | 1825 | @staticmethod |
1761 | 1826 | def _batch( |
1762 | 1827 | documents: Sequence[Mapping[str, Any]], batch_size: int |
|
0 commit comments