mistralai 1.10.0__py3-none-any.whl → 1.11.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mistralai/_hooks/tracing.py +28 -3
- mistralai/_version.py +3 -3
- mistralai/accesses.py +22 -12
- mistralai/agents.py +88 -44
- mistralai/basesdk.py +6 -0
- mistralai/chat.py +96 -40
- mistralai/classifiers.py +48 -23
- mistralai/conversations.py +186 -64
- mistralai/documents.py +72 -26
- mistralai/embeddings.py +24 -9
- mistralai/extra/README.md +1 -1
- mistralai/extra/mcp/auth.py +10 -11
- mistralai/extra/mcp/base.py +17 -16
- mistralai/extra/mcp/sse.py +13 -15
- mistralai/extra/mcp/stdio.py +5 -6
- mistralai/extra/observability/otel.py +47 -68
- mistralai/extra/run/context.py +33 -43
- mistralai/extra/run/result.py +29 -30
- mistralai/extra/run/tools.py +8 -9
- mistralai/extra/struct_chat.py +15 -8
- mistralai/extra/utils/response_format.py +5 -3
- mistralai/files.py +58 -24
- mistralai/fim.py +20 -12
- mistralai/httpclient.py +0 -1
- mistralai/jobs.py +65 -26
- mistralai/libraries.py +20 -10
- mistralai/mistral_agents.py +438 -30
- mistralai/mistral_jobs.py +62 -17
- mistralai/models/__init__.py +46 -1
- mistralai/models/agent.py +1 -1
- mistralai/models/agentconversation.py +1 -1
- mistralai/models/agenthandoffdoneevent.py +1 -1
- mistralai/models/agenthandoffentry.py +3 -2
- mistralai/models/agenthandoffstartedevent.py +1 -1
- mistralai/models/agents_api_v1_agents_get_versionop.py +21 -0
- mistralai/models/agents_api_v1_agents_list_versionsop.py +33 -0
- mistralai/models/agents_api_v1_agents_listop.py +5 -1
- mistralai/models/agents_api_v1_conversations_listop.py +1 -1
- mistralai/models/agentscompletionrequest.py +2 -5
- mistralai/models/agentscompletionstreamrequest.py +2 -5
- mistralai/models/archiveftmodelout.py +1 -1
- mistralai/models/assistantmessage.py +1 -1
- mistralai/models/audiochunk.py +1 -1
- mistralai/models/audioencoding.py +18 -0
- mistralai/models/audioformat.py +17 -0
- mistralai/models/basemodelcard.py +1 -1
- mistralai/models/batchjobin.py +18 -9
- mistralai/models/batchjobout.py +6 -1
- mistralai/models/batchjobsout.py +1 -1
- mistralai/models/batchrequest.py +48 -0
- mistralai/models/chatcompletionchoice.py +10 -5
- mistralai/models/chatcompletionrequest.py +2 -5
- mistralai/models/chatcompletionstreamrequest.py +2 -5
- mistralai/models/classificationrequest.py +37 -3
- mistralai/models/classifierdetailedjobout.py +4 -2
- mistralai/models/classifierftmodelout.py +3 -2
- mistralai/models/classifierjobout.py +4 -2
- mistralai/models/codeinterpretertool.py +1 -1
- mistralai/models/completiondetailedjobout.py +5 -2
- mistralai/models/completionftmodelout.py +3 -2
- mistralai/models/completionjobout.py +5 -2
- mistralai/models/completionresponsestreamchoice.py +9 -8
- mistralai/models/conversationappendrequest.py +4 -1
- mistralai/models/conversationappendstreamrequest.py +4 -1
- mistralai/models/conversationhistory.py +2 -1
- mistralai/models/conversationmessages.py +1 -1
- mistralai/models/conversationrequest.py +5 -1
- mistralai/models/conversationresponse.py +2 -1
- mistralai/models/conversationrestartrequest.py +4 -1
- mistralai/models/conversationrestartstreamrequest.py +4 -1
- mistralai/models/conversationstreamrequest.py +5 -1
- mistralai/models/documentlibrarytool.py +1 -1
- mistralai/models/documenturlchunk.py +1 -1
- mistralai/models/embeddingdtype.py +7 -1
- mistralai/models/embeddingrequest.py +11 -3
- mistralai/models/encodingformat.py +4 -1
- mistralai/models/entitytype.py +8 -1
- mistralai/models/filepurpose.py +8 -1
- mistralai/models/files_api_routes_list_filesop.py +4 -11
- mistralai/models/files_api_routes_upload_fileop.py +2 -6
- mistralai/models/fileschema.py +3 -5
- mistralai/models/finetuneablemodeltype.py +4 -1
- mistralai/models/ftclassifierlossfunction.py +4 -1
- mistralai/models/ftmodelcard.py +1 -1
- mistralai/models/functioncallentry.py +3 -2
- mistralai/models/functioncallevent.py +1 -1
- mistralai/models/functionresultentry.py +3 -2
- mistralai/models/functiontool.py +1 -1
- mistralai/models/githubrepositoryin.py +1 -1
- mistralai/models/githubrepositoryout.py +1 -1
- mistralai/models/httpvalidationerror.py +4 -2
- mistralai/models/imagegenerationtool.py +1 -1
- mistralai/models/imageurlchunk.py +1 -1
- mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +40 -3
- mistralai/models/jobsout.py +1 -1
- mistralai/models/legacyjobmetadataout.py +1 -1
- mistralai/models/messageinputentry.py +9 -3
- mistralai/models/messageoutputentry.py +6 -3
- mistralai/models/messageoutputevent.py +4 -2
- mistralai/models/mistralerror.py +11 -7
- mistralai/models/mistralpromptmode.py +1 -1
- mistralai/models/modelconversation.py +1 -1
- mistralai/models/no_response_error.py +5 -1
- mistralai/models/ocrrequest.py +11 -1
- mistralai/models/ocrtableobject.py +4 -1
- mistralai/models/referencechunk.py +1 -1
- mistralai/models/requestsource.py +5 -1
- mistralai/models/responsedoneevent.py +1 -1
- mistralai/models/responseerrorevent.py +1 -1
- mistralai/models/responseformats.py +5 -1
- mistralai/models/responsestartedevent.py +1 -1
- mistralai/models/responsevalidationerror.py +2 -0
- mistralai/models/retrievefileout.py +3 -5
- mistralai/models/sampletype.py +7 -1
- mistralai/models/sdkerror.py +2 -0
- mistralai/models/shareenum.py +7 -1
- mistralai/models/sharingdelete.py +2 -4
- mistralai/models/sharingin.py +3 -5
- mistralai/models/source.py +8 -1
- mistralai/models/systemmessage.py +1 -1
- mistralai/models/textchunk.py +1 -1
- mistralai/models/thinkchunk.py +1 -1
- mistralai/models/timestampgranularity.py +1 -1
- mistralai/models/tool.py +2 -6
- mistralai/models/toolcall.py +2 -6
- mistralai/models/toolchoice.py +2 -6
- mistralai/models/toolchoiceenum.py +6 -1
- mistralai/models/toolexecutiondeltaevent.py +2 -1
- mistralai/models/toolexecutiondoneevent.py +2 -1
- mistralai/models/toolexecutionentry.py +4 -2
- mistralai/models/toolexecutionstartedevent.py +2 -1
- mistralai/models/toolfilechunk.py +13 -5
- mistralai/models/toolmessage.py +1 -1
- mistralai/models/toolreferencechunk.py +15 -5
- mistralai/models/tooltypes.py +1 -1
- mistralai/models/transcriptionsegmentchunk.py +1 -1
- mistralai/models/transcriptionstreamdone.py +1 -1
- mistralai/models/transcriptionstreamlanguage.py +1 -1
- mistralai/models/transcriptionstreamsegmentdelta.py +1 -1
- mistralai/models/transcriptionstreamtextdelta.py +1 -1
- mistralai/models/unarchiveftmodelout.py +1 -1
- mistralai/models/uploadfileout.py +3 -5
- mistralai/models/usermessage.py +1 -1
- mistralai/models/wandbintegration.py +1 -1
- mistralai/models/wandbintegrationout.py +1 -1
- mistralai/models/websearchpremiumtool.py +1 -1
- mistralai/models/websearchtool.py +1 -1
- mistralai/models_.py +24 -12
- mistralai/ocr.py +38 -10
- mistralai/sdk.py +2 -2
- mistralai/transcriptions.py +28 -12
- mistralai/types/basemodel.py +41 -3
- mistralai/utils/__init__.py +0 -3
- mistralai/utils/annotations.py +32 -8
- mistralai/utils/enums.py +60 -0
- mistralai/utils/forms.py +21 -10
- mistralai/utils/queryparams.py +14 -2
- mistralai/utils/requestbodies.py +3 -3
- mistralai/utils/retries.py +69 -5
- mistralai/utils/serializers.py +0 -20
- mistralai/utils/unmarshal_json_response.py +15 -1
- {mistralai-1.10.0.dist-info → mistralai-1.11.1.dist-info}/METADATA +144 -159
- mistralai-1.11.1.dist-info/RECORD +495 -0
- {mistralai-1.10.0.dist-info → mistralai-1.11.1.dist-info}/WHEEL +1 -1
- mistralai_azure/_version.py +3 -3
- mistralai_azure/basesdk.py +21 -5
- mistralai_azure/chat.py +82 -109
- mistralai_azure/httpclient.py +0 -1
- mistralai_azure/models/__init__.py +66 -4
- mistralai_azure/models/assistantmessage.py +1 -1
- mistralai_azure/models/chatcompletionchoice.py +10 -7
- mistralai_azure/models/chatcompletionrequest.py +24 -10
- mistralai_azure/models/chatcompletionstreamrequest.py +24 -10
- mistralai_azure/models/completionresponsestreamchoice.py +11 -7
- mistralai_azure/models/documenturlchunk.py +1 -1
- mistralai_azure/models/httpvalidationerror.py +15 -8
- mistralai_azure/models/imageurlchunk.py +1 -1
- mistralai_azure/models/mistralazureerror.py +30 -0
- mistralai_azure/models/mistralpromptmode.py +1 -1
- mistralai_azure/models/no_response_error.py +17 -0
- mistralai_azure/models/ocrpageobject.py +32 -5
- mistralai_azure/models/ocrrequest.py +20 -1
- mistralai_azure/models/ocrtableobject.py +34 -0
- mistralai_azure/models/prediction.py +4 -0
- mistralai_azure/models/referencechunk.py +1 -1
- mistralai_azure/models/responseformat.py +4 -2
- mistralai_azure/models/responseformats.py +5 -2
- mistralai_azure/models/responsevalidationerror.py +27 -0
- mistralai_azure/models/sdkerror.py +32 -14
- mistralai_azure/models/systemmessage.py +8 -4
- mistralai_azure/models/systemmessagecontentchunks.py +21 -0
- mistralai_azure/models/textchunk.py +1 -1
- mistralai_azure/models/thinkchunk.py +35 -0
- mistralai_azure/models/tool.py +2 -6
- mistralai_azure/models/toolcall.py +2 -6
- mistralai_azure/models/toolchoice.py +2 -6
- mistralai_azure/models/toolchoiceenum.py +6 -1
- mistralai_azure/models/toolmessage.py +1 -1
- mistralai_azure/models/tooltypes.py +1 -1
- mistralai_azure/models/usermessage.py +1 -1
- mistralai_azure/ocr.py +39 -40
- mistralai_azure/types/basemodel.py +41 -3
- mistralai_azure/utils/__init__.py +18 -8
- mistralai_azure/utils/annotations.py +32 -8
- mistralai_azure/utils/enums.py +60 -0
- mistralai_azure/utils/eventstreaming.py +10 -0
- mistralai_azure/utils/forms.py +21 -10
- mistralai_azure/utils/queryparams.py +14 -2
- mistralai_azure/utils/requestbodies.py +3 -3
- mistralai_azure/utils/retries.py +69 -5
- mistralai_azure/utils/serializers.py +3 -22
- mistralai_azure/utils/unmarshal_json_response.py +38 -0
- mistralai_gcp/_hooks/types.py +7 -0
- mistralai_gcp/_version.py +4 -4
- mistralai_gcp/basesdk.py +33 -25
- mistralai_gcp/chat.py +98 -109
- mistralai_gcp/fim.py +62 -85
- mistralai_gcp/httpclient.py +6 -17
- mistralai_gcp/models/__init__.py +321 -116
- mistralai_gcp/models/assistantmessage.py +2 -2
- mistralai_gcp/models/chatcompletionchoice.py +10 -7
- mistralai_gcp/models/chatcompletionrequest.py +38 -7
- mistralai_gcp/models/chatcompletionresponse.py +6 -6
- mistralai_gcp/models/chatcompletionstreamrequest.py +38 -7
- mistralai_gcp/models/completionresponsestreamchoice.py +12 -8
- mistralai_gcp/models/deltamessage.py +1 -1
- mistralai_gcp/models/fimcompletionrequest.py +9 -10
- mistralai_gcp/models/fimcompletionresponse.py +6 -6
- mistralai_gcp/models/fimcompletionstreamrequest.py +9 -10
- mistralai_gcp/models/httpvalidationerror.py +15 -8
- mistralai_gcp/models/imageurl.py +1 -1
- mistralai_gcp/models/imageurlchunk.py +1 -1
- mistralai_gcp/models/jsonschema.py +1 -1
- mistralai_gcp/models/mistralgcperror.py +30 -0
- mistralai_gcp/models/mistralpromptmode.py +8 -0
- mistralai_gcp/models/no_response_error.py +17 -0
- mistralai_gcp/models/prediction.py +4 -0
- mistralai_gcp/models/referencechunk.py +1 -1
- mistralai_gcp/models/responseformat.py +5 -3
- mistralai_gcp/models/responseformats.py +5 -2
- mistralai_gcp/models/responsevalidationerror.py +27 -0
- mistralai_gcp/models/sdkerror.py +32 -14
- mistralai_gcp/models/systemmessage.py +8 -4
- mistralai_gcp/models/systemmessagecontentchunks.py +21 -0
- mistralai_gcp/models/textchunk.py +1 -1
- mistralai_gcp/models/thinkchunk.py +35 -0
- mistralai_gcp/models/tool.py +2 -6
- mistralai_gcp/models/toolcall.py +2 -6
- mistralai_gcp/models/toolchoice.py +2 -6
- mistralai_gcp/models/toolchoiceenum.py +6 -1
- mistralai_gcp/models/toolmessage.py +2 -2
- mistralai_gcp/models/tooltypes.py +1 -1
- mistralai_gcp/models/usageinfo.py +71 -8
- mistralai_gcp/models/usermessage.py +2 -2
- mistralai_gcp/sdk.py +12 -10
- mistralai_gcp/sdkconfiguration.py +0 -7
- mistralai_gcp/types/basemodel.py +41 -3
- mistralai_gcp/utils/__init__.py +141 -46
- mistralai_gcp/utils/annotations.py +32 -8
- mistralai_gcp/utils/datetimes.py +23 -0
- mistralai_gcp/utils/enums.py +125 -25
- mistralai_gcp/utils/eventstreaming.py +10 -0
- mistralai_gcp/utils/forms.py +62 -30
- mistralai_gcp/utils/queryparams.py +14 -2
- mistralai_gcp/utils/requestbodies.py +3 -3
- mistralai_gcp/utils/retries.py +69 -5
- mistralai_gcp/utils/serializers.py +33 -23
- mistralai_gcp/utils/unmarshal_json_response.py +38 -0
- mistralai-1.10.0.dist-info/RECORD +0 -475
- {mistralai-1.10.0.dist-info → mistralai-1.11.1.dist-info}/licenses/LICENSE +0 -0
mistralai/documents.py
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
from .basesdk import BaseSDK
|
|
4
4
|
from mistralai import models, utils
|
|
5
5
|
from mistralai._hooks import HookContext
|
|
6
|
+
from mistralai.models import (
|
|
7
|
+
documentupdatein as models_documentupdatein,
|
|
8
|
+
file as models_file,
|
|
9
|
+
)
|
|
6
10
|
from mistralai.types import OptionalNullable, UNSET
|
|
7
11
|
from mistralai.utils import get_security_from_env
|
|
8
12
|
from mistralai.utils.unmarshal_json_response import unmarshal_json_response
|
|
@@ -76,6 +80,7 @@ class Documents(BaseSDK):
|
|
|
76
80
|
accept_header_value="application/json",
|
|
77
81
|
http_headers=http_headers,
|
|
78
82
|
security=self.sdk_configuration.security,
|
|
83
|
+
allow_empty_value=None,
|
|
79
84
|
timeout_ms=timeout_ms,
|
|
80
85
|
)
|
|
81
86
|
|
|
@@ -92,7 +97,7 @@ class Documents(BaseSDK):
|
|
|
92
97
|
config=self.sdk_configuration,
|
|
93
98
|
base_url=base_url or "",
|
|
94
99
|
operation_id="libraries_documents_list_v1",
|
|
95
|
-
oauth2_scopes=
|
|
100
|
+
oauth2_scopes=None,
|
|
96
101
|
security_source=get_security_from_env(
|
|
97
102
|
self.sdk_configuration.security, models.Security
|
|
98
103
|
),
|
|
@@ -183,6 +188,7 @@ class Documents(BaseSDK):
|
|
|
183
188
|
accept_header_value="application/json",
|
|
184
189
|
http_headers=http_headers,
|
|
185
190
|
security=self.sdk_configuration.security,
|
|
191
|
+
allow_empty_value=None,
|
|
186
192
|
timeout_ms=timeout_ms,
|
|
187
193
|
)
|
|
188
194
|
|
|
@@ -199,7 +205,7 @@ class Documents(BaseSDK):
|
|
|
199
205
|
config=self.sdk_configuration,
|
|
200
206
|
base_url=base_url or "",
|
|
201
207
|
operation_id="libraries_documents_list_v1",
|
|
202
|
-
oauth2_scopes=
|
|
208
|
+
oauth2_scopes=None,
|
|
203
209
|
security_source=get_security_from_env(
|
|
204
210
|
self.sdk_configuration.security, models.Security
|
|
205
211
|
),
|
|
@@ -230,7 +236,7 @@ class Documents(BaseSDK):
|
|
|
230
236
|
self,
|
|
231
237
|
*,
|
|
232
238
|
library_id: str,
|
|
233
|
-
file: Union[
|
|
239
|
+
file: Union[models_file.File, models_file.FileTypedDict],
|
|
234
240
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
235
241
|
server_url: Optional[str] = None,
|
|
236
242
|
timeout_ms: Optional[int] = None,
|
|
@@ -241,7 +247,15 @@ class Documents(BaseSDK):
|
|
|
241
247
|
Given a library, upload a new document to that library. It is queued for processing, it status will change it has been processed. The processing has to be completed in order be discoverable for the library search
|
|
242
248
|
|
|
243
249
|
:param library_id:
|
|
244
|
-
:param file: The File object (not file name) to be uploaded.
|
|
250
|
+
:param file: The File object (not file name) to be uploaded.
|
|
251
|
+
To upload a file and specify a custom file name you should format your request as such:
|
|
252
|
+
```bash
|
|
253
|
+
file=@path/to/your/file.jsonl;filename=custom_name.jsonl
|
|
254
|
+
```
|
|
255
|
+
Otherwise, you can just keep the original file name:
|
|
256
|
+
```bash
|
|
257
|
+
file=@path/to/your/file.jsonl
|
|
258
|
+
```
|
|
245
259
|
:param retries: Override the default retry configuration for this method
|
|
246
260
|
:param server_url: Override the default server URL for this method
|
|
247
261
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -284,6 +298,7 @@ class Documents(BaseSDK):
|
|
|
284
298
|
"multipart",
|
|
285
299
|
models.LibrariesDocumentsUploadV1DocumentUpload,
|
|
286
300
|
),
|
|
301
|
+
allow_empty_value=None,
|
|
287
302
|
timeout_ms=timeout_ms,
|
|
288
303
|
)
|
|
289
304
|
|
|
@@ -300,7 +315,7 @@ class Documents(BaseSDK):
|
|
|
300
315
|
config=self.sdk_configuration,
|
|
301
316
|
base_url=base_url or "",
|
|
302
317
|
operation_id="libraries_documents_upload_v1",
|
|
303
|
-
oauth2_scopes=
|
|
318
|
+
oauth2_scopes=None,
|
|
304
319
|
security_source=get_security_from_env(
|
|
305
320
|
self.sdk_configuration.security, models.Security
|
|
306
321
|
),
|
|
@@ -331,7 +346,7 @@ class Documents(BaseSDK):
|
|
|
331
346
|
self,
|
|
332
347
|
*,
|
|
333
348
|
library_id: str,
|
|
334
|
-
file: Union[
|
|
349
|
+
file: Union[models_file.File, models_file.FileTypedDict],
|
|
335
350
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
336
351
|
server_url: Optional[str] = None,
|
|
337
352
|
timeout_ms: Optional[int] = None,
|
|
@@ -342,7 +357,15 @@ class Documents(BaseSDK):
|
|
|
342
357
|
Given a library, upload a new document to that library. It is queued for processing, it status will change it has been processed. The processing has to be completed in order be discoverable for the library search
|
|
343
358
|
|
|
344
359
|
:param library_id:
|
|
345
|
-
:param file: The File object (not file name) to be uploaded.
|
|
360
|
+
:param file: The File object (not file name) to be uploaded.
|
|
361
|
+
To upload a file and specify a custom file name you should format your request as such:
|
|
362
|
+
```bash
|
|
363
|
+
file=@path/to/your/file.jsonl;filename=custom_name.jsonl
|
|
364
|
+
```
|
|
365
|
+
Otherwise, you can just keep the original file name:
|
|
366
|
+
```bash
|
|
367
|
+
file=@path/to/your/file.jsonl
|
|
368
|
+
```
|
|
346
369
|
:param retries: Override the default retry configuration for this method
|
|
347
370
|
:param server_url: Override the default server URL for this method
|
|
348
371
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -385,6 +408,7 @@ class Documents(BaseSDK):
|
|
|
385
408
|
"multipart",
|
|
386
409
|
models.LibrariesDocumentsUploadV1DocumentUpload,
|
|
387
410
|
),
|
|
411
|
+
allow_empty_value=None,
|
|
388
412
|
timeout_ms=timeout_ms,
|
|
389
413
|
)
|
|
390
414
|
|
|
@@ -401,7 +425,7 @@ class Documents(BaseSDK):
|
|
|
401
425
|
config=self.sdk_configuration,
|
|
402
426
|
base_url=base_url or "",
|
|
403
427
|
operation_id="libraries_documents_upload_v1",
|
|
404
|
-
oauth2_scopes=
|
|
428
|
+
oauth2_scopes=None,
|
|
405
429
|
security_source=get_security_from_env(
|
|
406
430
|
self.sdk_configuration.security, models.Security
|
|
407
431
|
),
|
|
@@ -477,6 +501,7 @@ class Documents(BaseSDK):
|
|
|
477
501
|
accept_header_value="application/json",
|
|
478
502
|
http_headers=http_headers,
|
|
479
503
|
security=self.sdk_configuration.security,
|
|
504
|
+
allow_empty_value=None,
|
|
480
505
|
timeout_ms=timeout_ms,
|
|
481
506
|
)
|
|
482
507
|
|
|
@@ -493,7 +518,7 @@ class Documents(BaseSDK):
|
|
|
493
518
|
config=self.sdk_configuration,
|
|
494
519
|
base_url=base_url or "",
|
|
495
520
|
operation_id="libraries_documents_get_v1",
|
|
496
|
-
oauth2_scopes=
|
|
521
|
+
oauth2_scopes=None,
|
|
497
522
|
security_source=get_security_from_env(
|
|
498
523
|
self.sdk_configuration.security, models.Security
|
|
499
524
|
),
|
|
@@ -569,6 +594,7 @@ class Documents(BaseSDK):
|
|
|
569
594
|
accept_header_value="application/json",
|
|
570
595
|
http_headers=http_headers,
|
|
571
596
|
security=self.sdk_configuration.security,
|
|
597
|
+
allow_empty_value=None,
|
|
572
598
|
timeout_ms=timeout_ms,
|
|
573
599
|
)
|
|
574
600
|
|
|
@@ -585,7 +611,7 @@ class Documents(BaseSDK):
|
|
|
585
611
|
config=self.sdk_configuration,
|
|
586
612
|
base_url=base_url or "",
|
|
587
613
|
operation_id="libraries_documents_get_v1",
|
|
588
|
-
oauth2_scopes=
|
|
614
|
+
oauth2_scopes=None,
|
|
589
615
|
security_source=get_security_from_env(
|
|
590
616
|
self.sdk_configuration.security, models.Security
|
|
591
617
|
),
|
|
@@ -619,7 +645,10 @@ class Documents(BaseSDK):
|
|
|
619
645
|
document_id: str,
|
|
620
646
|
name: OptionalNullable[str] = UNSET,
|
|
621
647
|
attributes: OptionalNullable[
|
|
622
|
-
Union[
|
|
648
|
+
Union[
|
|
649
|
+
Dict[str, models_documentupdatein.Attributes],
|
|
650
|
+
Dict[str, models_documentupdatein.AttributesTypedDict],
|
|
651
|
+
]
|
|
623
652
|
] = UNSET,
|
|
624
653
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
625
654
|
server_url: Optional[str] = None,
|
|
@@ -678,6 +707,7 @@ class Documents(BaseSDK):
|
|
|
678
707
|
"json",
|
|
679
708
|
models.DocumentUpdateIn,
|
|
680
709
|
),
|
|
710
|
+
allow_empty_value=None,
|
|
681
711
|
timeout_ms=timeout_ms,
|
|
682
712
|
)
|
|
683
713
|
|
|
@@ -694,7 +724,7 @@ class Documents(BaseSDK):
|
|
|
694
724
|
config=self.sdk_configuration,
|
|
695
725
|
base_url=base_url or "",
|
|
696
726
|
operation_id="libraries_documents_update_v1",
|
|
697
|
-
oauth2_scopes=
|
|
727
|
+
oauth2_scopes=None,
|
|
698
728
|
security_source=get_security_from_env(
|
|
699
729
|
self.sdk_configuration.security, models.Security
|
|
700
730
|
),
|
|
@@ -728,7 +758,10 @@ class Documents(BaseSDK):
|
|
|
728
758
|
document_id: str,
|
|
729
759
|
name: OptionalNullable[str] = UNSET,
|
|
730
760
|
attributes: OptionalNullable[
|
|
731
|
-
Union[
|
|
761
|
+
Union[
|
|
762
|
+
Dict[str, models_documentupdatein.Attributes],
|
|
763
|
+
Dict[str, models_documentupdatein.AttributesTypedDict],
|
|
764
|
+
]
|
|
732
765
|
] = UNSET,
|
|
733
766
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
734
767
|
server_url: Optional[str] = None,
|
|
@@ -787,6 +820,7 @@ class Documents(BaseSDK):
|
|
|
787
820
|
"json",
|
|
788
821
|
models.DocumentUpdateIn,
|
|
789
822
|
),
|
|
823
|
+
allow_empty_value=None,
|
|
790
824
|
timeout_ms=timeout_ms,
|
|
791
825
|
)
|
|
792
826
|
|
|
@@ -803,7 +837,7 @@ class Documents(BaseSDK):
|
|
|
803
837
|
config=self.sdk_configuration,
|
|
804
838
|
base_url=base_url or "",
|
|
805
839
|
operation_id="libraries_documents_update_v1",
|
|
806
|
-
oauth2_scopes=
|
|
840
|
+
oauth2_scopes=None,
|
|
807
841
|
security_source=get_security_from_env(
|
|
808
842
|
self.sdk_configuration.security, models.Security
|
|
809
843
|
),
|
|
@@ -879,6 +913,7 @@ class Documents(BaseSDK):
|
|
|
879
913
|
accept_header_value="application/json",
|
|
880
914
|
http_headers=http_headers,
|
|
881
915
|
security=self.sdk_configuration.security,
|
|
916
|
+
allow_empty_value=None,
|
|
882
917
|
timeout_ms=timeout_ms,
|
|
883
918
|
)
|
|
884
919
|
|
|
@@ -895,7 +930,7 @@ class Documents(BaseSDK):
|
|
|
895
930
|
config=self.sdk_configuration,
|
|
896
931
|
base_url=base_url or "",
|
|
897
932
|
operation_id="libraries_documents_delete_v1",
|
|
898
|
-
oauth2_scopes=
|
|
933
|
+
oauth2_scopes=None,
|
|
899
934
|
security_source=get_security_from_env(
|
|
900
935
|
self.sdk_configuration.security, models.Security
|
|
901
936
|
),
|
|
@@ -971,6 +1006,7 @@ class Documents(BaseSDK):
|
|
|
971
1006
|
accept_header_value="application/json",
|
|
972
1007
|
http_headers=http_headers,
|
|
973
1008
|
security=self.sdk_configuration.security,
|
|
1009
|
+
allow_empty_value=None,
|
|
974
1010
|
timeout_ms=timeout_ms,
|
|
975
1011
|
)
|
|
976
1012
|
|
|
@@ -987,7 +1023,7 @@ class Documents(BaseSDK):
|
|
|
987
1023
|
config=self.sdk_configuration,
|
|
988
1024
|
base_url=base_url or "",
|
|
989
1025
|
operation_id="libraries_documents_delete_v1",
|
|
990
|
-
oauth2_scopes=
|
|
1026
|
+
oauth2_scopes=None,
|
|
991
1027
|
security_source=get_security_from_env(
|
|
992
1028
|
self.sdk_configuration.security, models.Security
|
|
993
1029
|
),
|
|
@@ -1063,6 +1099,7 @@ class Documents(BaseSDK):
|
|
|
1063
1099
|
accept_header_value="application/json",
|
|
1064
1100
|
http_headers=http_headers,
|
|
1065
1101
|
security=self.sdk_configuration.security,
|
|
1102
|
+
allow_empty_value=None,
|
|
1066
1103
|
timeout_ms=timeout_ms,
|
|
1067
1104
|
)
|
|
1068
1105
|
|
|
@@ -1079,7 +1116,7 @@ class Documents(BaseSDK):
|
|
|
1079
1116
|
config=self.sdk_configuration,
|
|
1080
1117
|
base_url=base_url or "",
|
|
1081
1118
|
operation_id="libraries_documents_get_text_content_v1",
|
|
1082
|
-
oauth2_scopes=
|
|
1119
|
+
oauth2_scopes=None,
|
|
1083
1120
|
security_source=get_security_from_env(
|
|
1084
1121
|
self.sdk_configuration.security, models.Security
|
|
1085
1122
|
),
|
|
@@ -1155,6 +1192,7 @@ class Documents(BaseSDK):
|
|
|
1155
1192
|
accept_header_value="application/json",
|
|
1156
1193
|
http_headers=http_headers,
|
|
1157
1194
|
security=self.sdk_configuration.security,
|
|
1195
|
+
allow_empty_value=None,
|
|
1158
1196
|
timeout_ms=timeout_ms,
|
|
1159
1197
|
)
|
|
1160
1198
|
|
|
@@ -1171,7 +1209,7 @@ class Documents(BaseSDK):
|
|
|
1171
1209
|
config=self.sdk_configuration,
|
|
1172
1210
|
base_url=base_url or "",
|
|
1173
1211
|
operation_id="libraries_documents_get_text_content_v1",
|
|
1174
|
-
oauth2_scopes=
|
|
1212
|
+
oauth2_scopes=None,
|
|
1175
1213
|
security_source=get_security_from_env(
|
|
1176
1214
|
self.sdk_configuration.security, models.Security
|
|
1177
1215
|
),
|
|
@@ -1247,6 +1285,7 @@ class Documents(BaseSDK):
|
|
|
1247
1285
|
accept_header_value="application/json",
|
|
1248
1286
|
http_headers=http_headers,
|
|
1249
1287
|
security=self.sdk_configuration.security,
|
|
1288
|
+
allow_empty_value=None,
|
|
1250
1289
|
timeout_ms=timeout_ms,
|
|
1251
1290
|
)
|
|
1252
1291
|
|
|
@@ -1263,7 +1302,7 @@ class Documents(BaseSDK):
|
|
|
1263
1302
|
config=self.sdk_configuration,
|
|
1264
1303
|
base_url=base_url or "",
|
|
1265
1304
|
operation_id="libraries_documents_get_status_v1",
|
|
1266
|
-
oauth2_scopes=
|
|
1305
|
+
oauth2_scopes=None,
|
|
1267
1306
|
security_source=get_security_from_env(
|
|
1268
1307
|
self.sdk_configuration.security, models.Security
|
|
1269
1308
|
),
|
|
@@ -1339,6 +1378,7 @@ class Documents(BaseSDK):
|
|
|
1339
1378
|
accept_header_value="application/json",
|
|
1340
1379
|
http_headers=http_headers,
|
|
1341
1380
|
security=self.sdk_configuration.security,
|
|
1381
|
+
allow_empty_value=None,
|
|
1342
1382
|
timeout_ms=timeout_ms,
|
|
1343
1383
|
)
|
|
1344
1384
|
|
|
@@ -1355,7 +1395,7 @@ class Documents(BaseSDK):
|
|
|
1355
1395
|
config=self.sdk_configuration,
|
|
1356
1396
|
base_url=base_url or "",
|
|
1357
1397
|
operation_id="libraries_documents_get_status_v1",
|
|
1358
|
-
oauth2_scopes=
|
|
1398
|
+
oauth2_scopes=None,
|
|
1359
1399
|
security_source=get_security_from_env(
|
|
1360
1400
|
self.sdk_configuration.security, models.Security
|
|
1361
1401
|
),
|
|
@@ -1431,6 +1471,7 @@ class Documents(BaseSDK):
|
|
|
1431
1471
|
accept_header_value="application/json",
|
|
1432
1472
|
http_headers=http_headers,
|
|
1433
1473
|
security=self.sdk_configuration.security,
|
|
1474
|
+
allow_empty_value=None,
|
|
1434
1475
|
timeout_ms=timeout_ms,
|
|
1435
1476
|
)
|
|
1436
1477
|
|
|
@@ -1447,7 +1488,7 @@ class Documents(BaseSDK):
|
|
|
1447
1488
|
config=self.sdk_configuration,
|
|
1448
1489
|
base_url=base_url or "",
|
|
1449
1490
|
operation_id="libraries_documents_get_signed_url_v1",
|
|
1450
|
-
oauth2_scopes=
|
|
1491
|
+
oauth2_scopes=None,
|
|
1451
1492
|
security_source=get_security_from_env(
|
|
1452
1493
|
self.sdk_configuration.security, models.Security
|
|
1453
1494
|
),
|
|
@@ -1523,6 +1564,7 @@ class Documents(BaseSDK):
|
|
|
1523
1564
|
accept_header_value="application/json",
|
|
1524
1565
|
http_headers=http_headers,
|
|
1525
1566
|
security=self.sdk_configuration.security,
|
|
1567
|
+
allow_empty_value=None,
|
|
1526
1568
|
timeout_ms=timeout_ms,
|
|
1527
1569
|
)
|
|
1528
1570
|
|
|
@@ -1539,7 +1581,7 @@ class Documents(BaseSDK):
|
|
|
1539
1581
|
config=self.sdk_configuration,
|
|
1540
1582
|
base_url=base_url or "",
|
|
1541
1583
|
operation_id="libraries_documents_get_signed_url_v1",
|
|
1542
|
-
oauth2_scopes=
|
|
1584
|
+
oauth2_scopes=None,
|
|
1543
1585
|
security_source=get_security_from_env(
|
|
1544
1586
|
self.sdk_configuration.security, models.Security
|
|
1545
1587
|
),
|
|
@@ -1615,6 +1657,7 @@ class Documents(BaseSDK):
|
|
|
1615
1657
|
accept_header_value="application/json",
|
|
1616
1658
|
http_headers=http_headers,
|
|
1617
1659
|
security=self.sdk_configuration.security,
|
|
1660
|
+
allow_empty_value=None,
|
|
1618
1661
|
timeout_ms=timeout_ms,
|
|
1619
1662
|
)
|
|
1620
1663
|
|
|
@@ -1631,7 +1674,7 @@ class Documents(BaseSDK):
|
|
|
1631
1674
|
config=self.sdk_configuration,
|
|
1632
1675
|
base_url=base_url or "",
|
|
1633
1676
|
operation_id="libraries_documents_get_extracted_text_signed_url_v1",
|
|
1634
|
-
oauth2_scopes=
|
|
1677
|
+
oauth2_scopes=None,
|
|
1635
1678
|
security_source=get_security_from_env(
|
|
1636
1679
|
self.sdk_configuration.security, models.Security
|
|
1637
1680
|
),
|
|
@@ -1707,6 +1750,7 @@ class Documents(BaseSDK):
|
|
|
1707
1750
|
accept_header_value="application/json",
|
|
1708
1751
|
http_headers=http_headers,
|
|
1709
1752
|
security=self.sdk_configuration.security,
|
|
1753
|
+
allow_empty_value=None,
|
|
1710
1754
|
timeout_ms=timeout_ms,
|
|
1711
1755
|
)
|
|
1712
1756
|
|
|
@@ -1723,7 +1767,7 @@ class Documents(BaseSDK):
|
|
|
1723
1767
|
config=self.sdk_configuration,
|
|
1724
1768
|
base_url=base_url or "",
|
|
1725
1769
|
operation_id="libraries_documents_get_extracted_text_signed_url_v1",
|
|
1726
|
-
oauth2_scopes=
|
|
1770
|
+
oauth2_scopes=None,
|
|
1727
1771
|
security_source=get_security_from_env(
|
|
1728
1772
|
self.sdk_configuration.security, models.Security
|
|
1729
1773
|
),
|
|
@@ -1799,6 +1843,7 @@ class Documents(BaseSDK):
|
|
|
1799
1843
|
accept_header_value="application/json",
|
|
1800
1844
|
http_headers=http_headers,
|
|
1801
1845
|
security=self.sdk_configuration.security,
|
|
1846
|
+
allow_empty_value=None,
|
|
1802
1847
|
timeout_ms=timeout_ms,
|
|
1803
1848
|
)
|
|
1804
1849
|
|
|
@@ -1815,7 +1860,7 @@ class Documents(BaseSDK):
|
|
|
1815
1860
|
config=self.sdk_configuration,
|
|
1816
1861
|
base_url=base_url or "",
|
|
1817
1862
|
operation_id="libraries_documents_reprocess_v1",
|
|
1818
|
-
oauth2_scopes=
|
|
1863
|
+
oauth2_scopes=None,
|
|
1819
1864
|
security_source=get_security_from_env(
|
|
1820
1865
|
self.sdk_configuration.security, models.Security
|
|
1821
1866
|
),
|
|
@@ -1891,6 +1936,7 @@ class Documents(BaseSDK):
|
|
|
1891
1936
|
accept_header_value="application/json",
|
|
1892
1937
|
http_headers=http_headers,
|
|
1893
1938
|
security=self.sdk_configuration.security,
|
|
1939
|
+
allow_empty_value=None,
|
|
1894
1940
|
timeout_ms=timeout_ms,
|
|
1895
1941
|
)
|
|
1896
1942
|
|
|
@@ -1907,7 +1953,7 @@ class Documents(BaseSDK):
|
|
|
1907
1953
|
config=self.sdk_configuration,
|
|
1908
1954
|
base_url=base_url or "",
|
|
1909
1955
|
operation_id="libraries_documents_reprocess_v1",
|
|
1910
|
-
oauth2_scopes=
|
|
1956
|
+
oauth2_scopes=None,
|
|
1911
1957
|
security_source=get_security_from_env(
|
|
1912
1958
|
self.sdk_configuration.security, models.Security
|
|
1913
1959
|
),
|
mistralai/embeddings.py
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
from .basesdk import BaseSDK
|
|
4
4
|
from mistralai import models, utils
|
|
5
5
|
from mistralai._hooks import HookContext
|
|
6
|
+
from mistralai.models import (
|
|
7
|
+
embeddingdtype as models_embeddingdtype,
|
|
8
|
+
embeddingrequest as models_embeddingrequest,
|
|
9
|
+
encodingformat as models_encodingformat,
|
|
10
|
+
)
|
|
6
11
|
from mistralai.types import OptionalNullable, UNSET
|
|
7
12
|
from mistralai.utils import get_security_from_env
|
|
8
13
|
from mistralai.utils.unmarshal_json_response import unmarshal_json_response
|
|
9
|
-
from typing import Any, Mapping, Optional, Union
|
|
14
|
+
from typing import Any, Dict, Mapping, Optional, Union
|
|
10
15
|
|
|
11
16
|
|
|
12
17
|
class Embeddings(BaseSDK):
|
|
@@ -17,11 +22,13 @@ class Embeddings(BaseSDK):
|
|
|
17
22
|
*,
|
|
18
23
|
model: str,
|
|
19
24
|
inputs: Union[
|
|
20
|
-
|
|
25
|
+
models_embeddingrequest.EmbeddingRequestInputs,
|
|
26
|
+
models_embeddingrequest.EmbeddingRequestInputsTypedDict,
|
|
21
27
|
],
|
|
28
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
22
29
|
output_dimension: OptionalNullable[int] = UNSET,
|
|
23
|
-
output_dtype: Optional[
|
|
24
|
-
encoding_format: Optional[
|
|
30
|
+
output_dtype: Optional[models_embeddingdtype.EmbeddingDtype] = None,
|
|
31
|
+
encoding_format: Optional[models_encodingformat.EncodingFormat] = None,
|
|
25
32
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
26
33
|
server_url: Optional[str] = None,
|
|
27
34
|
timeout_ms: Optional[int] = None,
|
|
@@ -33,6 +40,7 @@ class Embeddings(BaseSDK):
|
|
|
33
40
|
|
|
34
41
|
:param model: The ID of the model to be used for embedding.
|
|
35
42
|
:param inputs: The text content to be embedded, can be a string or an array of strings for fast processing in bulk.
|
|
43
|
+
:param metadata:
|
|
36
44
|
:param output_dimension: The dimension of the output embeddings when feature available. If not provided, a default output dimension will be used.
|
|
37
45
|
:param output_dtype:
|
|
38
46
|
:param encoding_format:
|
|
@@ -53,6 +61,7 @@ class Embeddings(BaseSDK):
|
|
|
53
61
|
|
|
54
62
|
request = models.EmbeddingRequest(
|
|
55
63
|
model=model,
|
|
64
|
+
metadata=metadata,
|
|
56
65
|
inputs=inputs,
|
|
57
66
|
output_dimension=output_dimension,
|
|
58
67
|
output_dtype=output_dtype,
|
|
@@ -75,6 +84,7 @@ class Embeddings(BaseSDK):
|
|
|
75
84
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
76
85
|
request, False, False, "json", models.EmbeddingRequest
|
|
77
86
|
),
|
|
87
|
+
allow_empty_value=None,
|
|
78
88
|
timeout_ms=timeout_ms,
|
|
79
89
|
)
|
|
80
90
|
|
|
@@ -91,7 +101,7 @@ class Embeddings(BaseSDK):
|
|
|
91
101
|
config=self.sdk_configuration,
|
|
92
102
|
base_url=base_url or "",
|
|
93
103
|
operation_id="embeddings_v1_embeddings_post",
|
|
94
|
-
oauth2_scopes=
|
|
104
|
+
oauth2_scopes=None,
|
|
95
105
|
security_source=get_security_from_env(
|
|
96
106
|
self.sdk_configuration.security, models.Security
|
|
97
107
|
),
|
|
@@ -123,11 +133,13 @@ class Embeddings(BaseSDK):
|
|
|
123
133
|
*,
|
|
124
134
|
model: str,
|
|
125
135
|
inputs: Union[
|
|
126
|
-
|
|
136
|
+
models_embeddingrequest.EmbeddingRequestInputs,
|
|
137
|
+
models_embeddingrequest.EmbeddingRequestInputsTypedDict,
|
|
127
138
|
],
|
|
139
|
+
metadata: OptionalNullable[Dict[str, Any]] = UNSET,
|
|
128
140
|
output_dimension: OptionalNullable[int] = UNSET,
|
|
129
|
-
output_dtype: Optional[
|
|
130
|
-
encoding_format: Optional[
|
|
141
|
+
output_dtype: Optional[models_embeddingdtype.EmbeddingDtype] = None,
|
|
142
|
+
encoding_format: Optional[models_encodingformat.EncodingFormat] = None,
|
|
131
143
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
132
144
|
server_url: Optional[str] = None,
|
|
133
145
|
timeout_ms: Optional[int] = None,
|
|
@@ -139,6 +151,7 @@ class Embeddings(BaseSDK):
|
|
|
139
151
|
|
|
140
152
|
:param model: The ID of the model to be used for embedding.
|
|
141
153
|
:param inputs: The text content to be embedded, can be a string or an array of strings for fast processing in bulk.
|
|
154
|
+
:param metadata:
|
|
142
155
|
:param output_dimension: The dimension of the output embeddings when feature available. If not provided, a default output dimension will be used.
|
|
143
156
|
:param output_dtype:
|
|
144
157
|
:param encoding_format:
|
|
@@ -159,6 +172,7 @@ class Embeddings(BaseSDK):
|
|
|
159
172
|
|
|
160
173
|
request = models.EmbeddingRequest(
|
|
161
174
|
model=model,
|
|
175
|
+
metadata=metadata,
|
|
162
176
|
inputs=inputs,
|
|
163
177
|
output_dimension=output_dimension,
|
|
164
178
|
output_dtype=output_dtype,
|
|
@@ -181,6 +195,7 @@ class Embeddings(BaseSDK):
|
|
|
181
195
|
get_serialized_body=lambda: utils.serialize_request_body(
|
|
182
196
|
request, False, False, "json", models.EmbeddingRequest
|
|
183
197
|
),
|
|
198
|
+
allow_empty_value=None,
|
|
184
199
|
timeout_ms=timeout_ms,
|
|
185
200
|
)
|
|
186
201
|
|
|
@@ -197,7 +212,7 @@ class Embeddings(BaseSDK):
|
|
|
197
212
|
config=self.sdk_configuration,
|
|
198
213
|
base_url=base_url or "",
|
|
199
214
|
operation_id="embeddings_v1_embeddings_post",
|
|
200
|
-
oauth2_scopes=
|
|
215
|
+
oauth2_scopes=None,
|
|
201
216
|
security_source=get_security_from_env(
|
|
202
217
|
self.sdk_configuration.security, models.Security
|
|
203
218
|
),
|
mistralai/extra/README.md
CHANGED
|
@@ -34,7 +34,7 @@ class Chat(BaseSDK):
|
|
|
34
34
|
|
|
35
35
|
3. Now build the SDK with the custom code:
|
|
36
36
|
```bash
|
|
37
|
-
rm -rf dist;
|
|
37
|
+
rm -rf dist; uv build; uv pip install --reinstall ~/client-python/dist/mistralai-1.4.1-py3-none-any.whl
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
4. And now you should be able to call the custom method:
|
mistralai/extra/mcp/auth.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import logging
|
|
2
2
|
|
|
3
|
-
from authlib.oauth2.rfc8414 import AuthorizationServerMetadata
|
|
4
|
-
from authlib.integrations.httpx_client import AsyncOAuth2Client as AsyncOAuth2ClientBase
|
|
5
3
|
import httpx
|
|
6
|
-
import
|
|
4
|
+
from authlib.integrations.httpx_client import AsyncOAuth2Client as AsyncOAuth2ClientBase
|
|
5
|
+
from authlib.oauth2.rfc8414 import AuthorizationServerMetadata
|
|
7
6
|
|
|
8
7
|
from mistralai.types import BaseModel
|
|
9
8
|
|
|
@@ -16,8 +15,8 @@ class Oauth2AuthorizationScheme(BaseModel):
|
|
|
16
15
|
authorization_url: str
|
|
17
16
|
token_url: str
|
|
18
17
|
scope: list[str]
|
|
19
|
-
description:
|
|
20
|
-
refresh_url:
|
|
18
|
+
description: str | None = None
|
|
19
|
+
refresh_url: str | None = None
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
class OAuthParams(BaseModel):
|
|
@@ -42,7 +41,7 @@ class AsyncOAuth2Client(AsyncOAuth2ClientBase):
|
|
|
42
41
|
|
|
43
42
|
async def get_well_known_authorization_server_metadata(
|
|
44
43
|
server_url: str,
|
|
45
|
-
) ->
|
|
44
|
+
) -> AuthorizationServerMetadata | None:
|
|
46
45
|
"""Fetch the metadata from the well-known location.
|
|
47
46
|
|
|
48
47
|
This should be available on MCP servers as described by the specification:
|
|
@@ -123,10 +122,10 @@ async def dynamic_client_registration(
|
|
|
123
122
|
async def build_oauth_params(
|
|
124
123
|
server_url: str,
|
|
125
124
|
redirect_url: str,
|
|
126
|
-
client_id:
|
|
127
|
-
client_secret:
|
|
128
|
-
scope:
|
|
129
|
-
async_client:
|
|
125
|
+
client_id: str | None = None,
|
|
126
|
+
client_secret: str | None = None,
|
|
127
|
+
scope: list[str] | None = None,
|
|
128
|
+
async_client: httpx.AsyncClient | None = None,
|
|
130
129
|
) -> OAuthParams:
|
|
131
130
|
"""Get issuer metadata and build the oauth required params."""
|
|
132
131
|
metadata = await get_oauth_server_metadata(server_url=server_url)
|
mistralai/extra/mcp/base.py
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
from typing import Optional, Union
|
|
2
1
|
import logging
|
|
3
2
|
import typing
|
|
3
|
+
from collections.abc import Sequence
|
|
4
4
|
from contextlib import AsyncExitStack
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import Any, Protocol
|
|
6
6
|
|
|
7
|
-
from mcp import ClientSession
|
|
8
|
-
from mcp.types import
|
|
7
|
+
from mcp import ClientSession # pyright: ignore[reportMissingImports]
|
|
8
|
+
from mcp.types import ( # pyright: ignore[reportMissingImports]
|
|
9
|
+
ContentBlock,
|
|
10
|
+
ListPromptsResult,
|
|
11
|
+
)
|
|
9
12
|
|
|
10
13
|
from mistralai.extra.exceptions import MCPException
|
|
11
14
|
from mistralai.models import (
|
|
@@ -20,8 +23,8 @@ logger = logging.getLogger(__name__)
|
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
class MCPSystemPrompt(typing.TypedDict):
|
|
23
|
-
description:
|
|
24
|
-
messages: list[
|
|
26
|
+
description: str | None
|
|
27
|
+
messages: list[SystemMessageTypedDict | AssistantMessageTypedDict]
|
|
25
28
|
|
|
26
29
|
|
|
27
30
|
class MCPClientProtocol(Protocol):
|
|
@@ -29,7 +32,7 @@ class MCPClientProtocol(Protocol):
|
|
|
29
32
|
|
|
30
33
|
_name: str
|
|
31
34
|
|
|
32
|
-
async def initialize(self, exit_stack:
|
|
35
|
+
async def initialize(self, exit_stack: AsyncExitStack | None) -> None:
|
|
33
36
|
...
|
|
34
37
|
|
|
35
38
|
async def aclose(self) -> None:
|
|
@@ -39,7 +42,7 @@ class MCPClientProtocol(Protocol):
|
|
|
39
42
|
...
|
|
40
43
|
|
|
41
44
|
async def execute_tool(
|
|
42
|
-
self, name: str, arguments: dict
|
|
45
|
+
self, name: str, arguments: dict[str, Any]
|
|
43
46
|
) -> list[TextChunkTypedDict]:
|
|
44
47
|
...
|
|
45
48
|
|
|
@@ -57,20 +60,18 @@ class MCPClientBase(MCPClientProtocol):
|
|
|
57
60
|
|
|
58
61
|
_session: ClientSession
|
|
59
62
|
|
|
60
|
-
def __init__(self, name:
|
|
63
|
+
def __init__(self, name: str | None = None):
|
|
61
64
|
self._name = name or self.__class__.__name__
|
|
62
|
-
self._exit_stack:
|
|
65
|
+
self._exit_stack: AsyncExitStack | None = None
|
|
63
66
|
self._is_initialized = False
|
|
64
67
|
|
|
65
|
-
def _convert_content(
|
|
66
|
-
self, mcp_content: Union[TextContent, ImageContent, EmbeddedResource]
|
|
67
|
-
) -> TextChunkTypedDict:
|
|
68
|
+
def _convert_content(self, mcp_content: ContentBlock) -> TextChunkTypedDict:
|
|
68
69
|
if not mcp_content.type == "text":
|
|
69
70
|
raise MCPException("Only supporting text tool responses for now.")
|
|
70
71
|
return {"type": "text", "text": mcp_content.text}
|
|
71
72
|
|
|
72
73
|
def _convert_content_list(
|
|
73
|
-
self, mcp_contents:
|
|
74
|
+
self, mcp_contents: Sequence[ContentBlock]
|
|
74
75
|
) -> list[TextChunkTypedDict]:
|
|
75
76
|
content_chunks = []
|
|
76
77
|
for mcp_content in mcp_contents:
|
|
@@ -108,7 +109,7 @@ class MCPClientBase(MCPClientProtocol):
|
|
|
108
109
|
"description": prompt_result.description,
|
|
109
110
|
"messages": [
|
|
110
111
|
typing.cast(
|
|
111
|
-
|
|
112
|
+
SystemMessageTypedDict | AssistantMessageTypedDict,
|
|
112
113
|
{
|
|
113
114
|
"role": message.role,
|
|
114
115
|
"content": self._convert_content(mcp_content=message.content),
|
|
@@ -121,7 +122,7 @@ class MCPClientBase(MCPClientProtocol):
|
|
|
121
122
|
async def list_system_prompts(self) -> ListPromptsResult:
|
|
122
123
|
return await self._session.list_prompts()
|
|
123
124
|
|
|
124
|
-
async def initialize(self, exit_stack:
|
|
125
|
+
async def initialize(self, exit_stack: AsyncExitStack | None = None) -> None:
|
|
125
126
|
"""Initialize the MCP session."""
|
|
126
127
|
# client is already initialized so return
|
|
127
128
|
if self._is_initialized:
|