You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Streams a chat completion from the Meilisearch chat API.
824
+
825
+
Parameters
826
+
----------
827
+
workspace_uid:
828
+
Unique identifier of the chat workspace to use.
829
+
messages:
830
+
List of message dicts (e.g. {"role": "user", "content": "..."}) comprising the chat history.
831
+
model:
832
+
The model name to use for completion (should correspond to the LLM in workspace settings).
833
+
stream:
834
+
Whether to stream the response. Must be True for now (only streaming is supported).
835
+
836
+
Returns
837
+
-------
838
+
chunks:
839
+
Parsed chunks of the completion as Python dicts. Each chunk is a partial response (in OpenAI format).
840
+
Iteration ends when the completion is done.
841
+
842
+
Raises
843
+
------
844
+
MeilisearchApiError
845
+
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
846
+
MeilisearchCommunicationError
847
+
If a network error occurs.
848
+
ValueError
849
+
If stream=False is passed (not currently supported), or if workspace_uid is empty or contains path separators.
850
+
"""
851
+
ifnotstream:
852
+
# The API currently only supports streaming responses:
853
+
raiseValueError("Non-streaming chat completions are not supported. Use stream=True.")
854
+
855
+
# Basic security validation (only what's needed)
856
+
ifnotworkspace_uid:
857
+
raiseValueError("workspace_uid is required and cannot be empty")
858
+
if"/"inworkspace_uidor"\\"inworkspace_uid:
859
+
raiseValueError("Invalid workspace_uid: must not contain path separators")
Dictionary containing the list of chat workspaces and pagination information.
910
+
911
+
Raises
912
+
------
913
+
MeilisearchApiError
914
+
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
"""Get the settings for a specific chat workspace.
926
+
927
+
Parameters
928
+
----------
929
+
workspace_uid:
930
+
Unique identifier of the chat workspace.
931
+
932
+
Returns
933
+
-------
934
+
settings:
935
+
Dictionary containing the workspace settings.
936
+
937
+
Raises
938
+
------
939
+
MeilisearchApiError
940
+
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
941
+
ValueError
942
+
If workspace_uid is empty or contains path separators.
943
+
"""
944
+
# Basic security validation (only what's needed)
945
+
ifnotworkspace_uid:
946
+
raiseValueError("workspace_uid is required and cannot be empty")
947
+
if"/"inworkspace_uidor"\\"inworkspace_uid:
948
+
raiseValueError("Invalid workspace_uid: must not contain path separators")
"""Update the settings for a specific chat workspace.
956
+
957
+
Parameters
958
+
----------
959
+
workspace_uid:
960
+
Unique identifier of the chat workspace.
961
+
settings:
962
+
Dictionary containing the settings to update.
963
+
964
+
Returns
965
+
-------
966
+
settings:
967
+
Dictionary containing the updated workspace settings.
968
+
969
+
Raises
970
+
------
971
+
MeilisearchApiError
972
+
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
973
+
ValueError
974
+
If workspace_uid is empty or contains path separators, or if settings is empty.
975
+
"""
976
+
# Basic security validation (only what's needed)
977
+
ifnotworkspace_uid:
978
+
raiseValueError("workspace_uid is required and cannot be empty")
979
+
if"/"inworkspace_uidor"\\"inworkspace_uid:
980
+
raiseValueError("Invalid workspace_uid: must not contain path separators")
0 commit comments