mistralai 1.0.3__py3-none-any.whl → 1.2.0__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/__init__.py +4 -0
- mistralai/_hooks/sdkhooks.py +23 -4
- mistralai/_hooks/types.py +27 -9
- mistralai/_version.py +12 -0
- mistralai/agents.py +334 -164
- mistralai/basesdk.py +90 -5
- mistralai/batch.py +17 -0
- mistralai/chat.py +316 -166
- mistralai/classifiers.py +396 -0
- mistralai/embeddings.py +79 -55
- mistralai/files.py +487 -194
- mistralai/fim.py +206 -132
- mistralai/fine_tuning.py +3 -2
- mistralai/jobs.py +392 -263
- mistralai/mistral_jobs.py +733 -0
- mistralai/models/__init__.py +593 -50
- mistralai/models/agentscompletionrequest.py +70 -17
- mistralai/models/agentscompletionstreamrequest.py +72 -17
- mistralai/models/apiendpoint.py +9 -0
- mistralai/models/archiveftmodelout.py +15 -5
- mistralai/models/assistantmessage.py +22 -10
- mistralai/models/{modelcard.py → basemodelcard.py} +53 -14
- mistralai/models/batcherror.py +17 -0
- mistralai/models/batchjobin.py +58 -0
- mistralai/models/batchjobout.py +117 -0
- mistralai/models/batchjobsout.py +30 -0
- mistralai/models/batchjobstatus.py +15 -0
- mistralai/models/chatclassificationrequest.py +104 -0
- mistralai/models/chatcompletionchoice.py +13 -6
- mistralai/models/chatcompletionrequest.py +86 -21
- mistralai/models/chatcompletionresponse.py +8 -4
- mistralai/models/chatcompletionstreamrequest.py +88 -21
- mistralai/models/checkpointout.py +4 -3
- mistralai/models/classificationobject.py +21 -0
- mistralai/models/classificationrequest.py +59 -0
- mistralai/models/classificationresponse.py +21 -0
- mistralai/models/completionchunk.py +12 -5
- mistralai/models/completionevent.py +2 -3
- mistralai/models/completionresponsestreamchoice.py +22 -8
- mistralai/models/contentchunk.py +13 -10
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +5 -5
- mistralai/models/deletefileout.py +4 -3
- mistralai/models/deletemodelout.py +5 -4
- mistralai/models/deltamessage.py +23 -11
- mistralai/models/detailedjobout.py +70 -12
- mistralai/models/embeddingrequest.py +14 -9
- mistralai/models/embeddingresponse.py +7 -3
- mistralai/models/embeddingresponsedata.py +5 -4
- mistralai/models/eventout.py +11 -6
- mistralai/models/filepurpose.py +8 -0
- mistralai/models/files_api_routes_delete_fileop.py +5 -5
- mistralai/models/files_api_routes_download_fileop.py +16 -0
- mistralai/models/files_api_routes_list_filesop.py +96 -0
- mistralai/models/files_api_routes_retrieve_fileop.py +5 -5
- mistralai/models/files_api_routes_upload_fileop.py +33 -14
- mistralai/models/fileschema.py +22 -15
- mistralai/models/fimcompletionrequest.py +44 -16
- mistralai/models/fimcompletionresponse.py +8 -4
- mistralai/models/fimcompletionstreamrequest.py +44 -16
- mistralai/models/finetuneablemodel.py +7 -1
- mistralai/models/ftmodelcapabilitiesout.py +6 -4
- mistralai/models/ftmodelcard.py +121 -0
- mistralai/models/ftmodelout.py +39 -9
- mistralai/models/function.py +5 -4
- mistralai/models/functioncall.py +4 -3
- mistralai/models/functionname.py +17 -0
- mistralai/models/githubrepositoryin.py +24 -7
- mistralai/models/githubrepositoryout.py +24 -7
- mistralai/models/httpvalidationerror.py +1 -3
- mistralai/models/imageurl.py +47 -0
- mistralai/models/imageurlchunk.py +38 -0
- mistralai/models/jobin.py +24 -7
- mistralai/models/jobmetadataout.py +32 -8
- mistralai/models/jobout.py +65 -12
- mistralai/models/jobs_api_routes_batch_cancel_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +16 -0
- mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +95 -0
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +85 -18
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +5 -5
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +10 -6
- mistralai/models/jobsout.py +13 -5
- mistralai/models/legacyjobmetadataout.py +55 -9
- mistralai/models/listfilesout.py +7 -3
- mistralai/models/metricout.py +12 -8
- mistralai/models/modelcapabilities.py +9 -4
- mistralai/models/modellist.py +21 -7
- mistralai/models/responseformat.py +7 -8
- mistralai/models/responseformats.py +8 -0
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +25 -6
- mistralai/models/retrievefileout.py +25 -15
- mistralai/models/sampletype.py +6 -2
- mistralai/models/security.py +14 -5
- mistralai/models/source.py +3 -2
- mistralai/models/systemmessage.py +10 -9
- mistralai/models/textchunk.py +14 -5
- mistralai/models/tool.py +10 -9
- mistralai/models/toolcall.py +10 -8
- mistralai/models/toolchoice.py +29 -0
- mistralai/models/toolchoiceenum.py +7 -0
- mistralai/models/toolmessage.py +13 -6
- mistralai/models/tooltypes.py +8 -0
- mistralai/models/trainingfile.py +4 -4
- mistralai/models/trainingparameters.py +34 -8
- mistralai/models/trainingparametersin.py +36 -10
- mistralai/models/unarchiveftmodelout.py +15 -5
- mistralai/models/updateftmodelin.py +9 -6
- mistralai/models/uploadfileout.py +22 -15
- mistralai/models/usageinfo.py +4 -3
- mistralai/models/usermessage.py +42 -10
- mistralai/models/validationerror.py +5 -3
- mistralai/models/wandbintegration.py +23 -7
- mistralai/models/wandbintegrationout.py +23 -8
- mistralai/models_.py +416 -294
- mistralai/sdk.py +31 -19
- mistralai/sdkconfiguration.py +9 -11
- mistralai/utils/__init__.py +14 -1
- mistralai/utils/annotations.py +13 -2
- mistralai/utils/logger.py +4 -1
- mistralai/utils/retries.py +2 -1
- mistralai/utils/security.py +13 -6
- mistralai/utils/serializers.py +25 -0
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/METADATA +171 -66
- mistralai-1.2.0.dist-info/RECORD +276 -0
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +4 -0
- mistralai_azure/_hooks/sdkhooks.py +23 -4
- mistralai_azure/_hooks/types.py +27 -9
- mistralai_azure/_version.py +12 -0
- mistralai_azure/basesdk.py +91 -6
- mistralai_azure/chat.py +308 -166
- mistralai_azure/models/__init__.py +164 -16
- mistralai_azure/models/assistantmessage.py +29 -11
- mistralai_azure/models/chatcompletionchoice.py +15 -6
- mistralai_azure/models/chatcompletionrequest.py +94 -22
- mistralai_azure/models/chatcompletionresponse.py +8 -4
- mistralai_azure/models/chatcompletionstreamrequest.py +96 -22
- mistralai_azure/models/completionchunk.py +12 -5
- mistralai_azure/models/completionevent.py +2 -3
- mistralai_azure/models/completionresponsestreamchoice.py +19 -8
- mistralai_azure/models/contentchunk.py +4 -11
- mistralai_azure/models/deltamessage.py +30 -12
- mistralai_azure/models/function.py +5 -4
- mistralai_azure/models/functioncall.py +4 -3
- mistralai_azure/models/functionname.py +17 -0
- mistralai_azure/models/httpvalidationerror.py +1 -3
- mistralai_azure/models/responseformat.py +7 -8
- mistralai_azure/models/responseformats.py +8 -0
- mistralai_azure/models/security.py +13 -5
- mistralai_azure/models/systemmessage.py +10 -9
- mistralai_azure/models/textchunk.py +14 -5
- mistralai_azure/models/tool.py +10 -9
- mistralai_azure/models/toolcall.py +10 -8
- mistralai_azure/models/toolchoice.py +29 -0
- mistralai_azure/models/toolchoiceenum.py +7 -0
- mistralai_azure/models/toolmessage.py +20 -7
- mistralai_azure/models/tooltypes.py +8 -0
- mistralai_azure/models/usageinfo.py +4 -3
- mistralai_azure/models/usermessage.py +42 -10
- mistralai_azure/models/validationerror.py +5 -3
- mistralai_azure/sdkconfiguration.py +9 -11
- mistralai_azure/utils/__init__.py +16 -3
- mistralai_azure/utils/annotations.py +13 -2
- mistralai_azure/utils/forms.py +10 -9
- mistralai_azure/utils/headers.py +8 -8
- mistralai_azure/utils/logger.py +6 -0
- mistralai_azure/utils/queryparams.py +16 -14
- mistralai_azure/utils/retries.py +2 -1
- mistralai_azure/utils/security.py +12 -6
- mistralai_azure/utils/serializers.py +42 -8
- mistralai_azure/utils/url.py +13 -8
- mistralai_azure/utils/values.py +6 -0
- mistralai_gcp/__init__.py +4 -0
- mistralai_gcp/_hooks/sdkhooks.py +23 -4
- mistralai_gcp/_hooks/types.py +27 -9
- mistralai_gcp/_version.py +12 -0
- mistralai_gcp/basesdk.py +91 -6
- mistralai_gcp/chat.py +308 -166
- mistralai_gcp/fim.py +198 -132
- mistralai_gcp/models/__init__.py +186 -18
- mistralai_gcp/models/assistantmessage.py +29 -11
- mistralai_gcp/models/chatcompletionchoice.py +15 -6
- mistralai_gcp/models/chatcompletionrequest.py +91 -22
- mistralai_gcp/models/chatcompletionresponse.py +8 -4
- mistralai_gcp/models/chatcompletionstreamrequest.py +93 -22
- mistralai_gcp/models/completionchunk.py +12 -5
- mistralai_gcp/models/completionevent.py +2 -3
- mistralai_gcp/models/completionresponsestreamchoice.py +19 -8
- mistralai_gcp/models/contentchunk.py +4 -11
- mistralai_gcp/models/deltamessage.py +30 -12
- mistralai_gcp/models/fimcompletionrequest.py +51 -17
- mistralai_gcp/models/fimcompletionresponse.py +8 -4
- mistralai_gcp/models/fimcompletionstreamrequest.py +51 -17
- mistralai_gcp/models/function.py +5 -4
- mistralai_gcp/models/functioncall.py +4 -3
- mistralai_gcp/models/functionname.py +17 -0
- mistralai_gcp/models/httpvalidationerror.py +1 -3
- mistralai_gcp/models/responseformat.py +7 -8
- mistralai_gcp/models/responseformats.py +8 -0
- mistralai_gcp/models/security.py +13 -5
- mistralai_gcp/models/systemmessage.py +10 -9
- mistralai_gcp/models/textchunk.py +14 -5
- mistralai_gcp/models/tool.py +10 -9
- mistralai_gcp/models/toolcall.py +10 -8
- mistralai_gcp/models/toolchoice.py +29 -0
- mistralai_gcp/models/toolchoiceenum.py +7 -0
- mistralai_gcp/models/toolmessage.py +20 -7
- mistralai_gcp/models/tooltypes.py +8 -0
- mistralai_gcp/models/usageinfo.py +4 -3
- mistralai_gcp/models/usermessage.py +42 -10
- mistralai_gcp/models/validationerror.py +5 -3
- mistralai_gcp/sdk.py +6 -7
- mistralai_gcp/sdkconfiguration.py +9 -11
- mistralai_gcp/utils/__init__.py +16 -3
- mistralai_gcp/utils/annotations.py +13 -2
- mistralai_gcp/utils/forms.py +10 -9
- mistralai_gcp/utils/headers.py +8 -8
- mistralai_gcp/utils/logger.py +6 -0
- mistralai_gcp/utils/queryparams.py +16 -14
- mistralai_gcp/utils/retries.py +2 -1
- mistralai_gcp/utils/security.py +12 -6
- mistralai_gcp/utils/serializers.py +42 -8
- mistralai_gcp/utils/url.py +13 -8
- mistralai_gcp/utils/values.py +6 -0
- mistralai-1.0.3.dist-info/RECORD +0 -236
- {mistralai-1.0.3.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .functioncall import FunctionCall, FunctionCallTypedDict
|
|
5
|
-
from
|
|
5
|
+
from .tooltypes import ToolTypes
|
|
6
|
+
from mistralai_azure.types import BaseModel
|
|
6
7
|
from mistralai_azure.utils import validate_open_enum
|
|
7
8
|
from pydantic.functional_validators import PlainValidator
|
|
8
|
-
from typing import
|
|
9
|
-
from typing_extensions import Annotated, NotRequired
|
|
9
|
+
from typing import Optional
|
|
10
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
ToolTypes = Union[Literal["function"], UnrecognizedStr]
|
|
13
|
-
|
|
14
13
|
class ToolCallTypedDict(TypedDict):
|
|
15
14
|
function: FunctionCallTypedDict
|
|
16
15
|
id: NotRequired[str]
|
|
17
16
|
type: NotRequired[ToolTypes]
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
|
|
20
19
|
class ToolCall(BaseModel):
|
|
21
20
|
function: FunctionCall
|
|
21
|
+
|
|
22
22
|
id: Optional[str] = "null"
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
|
|
25
|
+
None
|
|
26
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .functionname import FunctionName, FunctionNameTypedDict
|
|
5
|
+
from .tooltypes import ToolTypes
|
|
6
|
+
from mistralai_azure.types import BaseModel
|
|
7
|
+
from mistralai_azure.utils import validate_open_enum
|
|
8
|
+
from pydantic.functional_validators import PlainValidator
|
|
9
|
+
from typing import Optional
|
|
10
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ToolChoiceTypedDict(TypedDict):
|
|
14
|
+
r"""ToolChoice is either a ToolChoiceEnum or a ToolChoice"""
|
|
15
|
+
|
|
16
|
+
function: FunctionNameTypedDict
|
|
17
|
+
r"""this restriction of `Function` is used to select a specific function to call"""
|
|
18
|
+
type: NotRequired[ToolTypes]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ToolChoice(BaseModel):
|
|
22
|
+
r"""ToolChoice is either a ToolChoiceEnum or a ToolChoice"""
|
|
23
|
+
|
|
24
|
+
function: FunctionName
|
|
25
|
+
r"""this restriction of `Function` is used to select a specific function to call"""
|
|
26
|
+
|
|
27
|
+
type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
|
|
28
|
+
None
|
|
29
|
+
)
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from mistralai_azure.types import
|
|
4
|
+
from mistralai_azure.types import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
Nullable,
|
|
7
|
+
OptionalNullable,
|
|
8
|
+
UNSET,
|
|
9
|
+
UNSET_SENTINEL,
|
|
10
|
+
)
|
|
5
11
|
from pydantic import model_serializer
|
|
6
|
-
from typing import Literal, Optional
|
|
7
|
-
from typing_extensions import NotRequired
|
|
12
|
+
from typing import Literal, Optional
|
|
13
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
14
|
|
|
9
15
|
|
|
10
16
|
ToolMessageRole = Literal["tool"]
|
|
11
17
|
|
|
18
|
+
|
|
12
19
|
class ToolMessageTypedDict(TypedDict):
|
|
13
20
|
content: str
|
|
14
21
|
tool_call_id: NotRequired[Nullable[str]]
|
|
15
22
|
name: NotRequired[Nullable[str]]
|
|
16
23
|
role: NotRequired[ToolMessageRole]
|
|
17
|
-
|
|
24
|
+
|
|
18
25
|
|
|
19
26
|
class ToolMessage(BaseModel):
|
|
20
27
|
content: str
|
|
28
|
+
|
|
21
29
|
tool_call_id: OptionalNullable[str] = UNSET
|
|
30
|
+
|
|
22
31
|
name: OptionalNullable[str] = UNSET
|
|
32
|
+
|
|
23
33
|
role: Optional[ToolMessageRole] = "tool"
|
|
24
|
-
|
|
34
|
+
|
|
25
35
|
@model_serializer(mode="wrap")
|
|
26
36
|
def serialize_model(self, handler):
|
|
27
37
|
optional_fields = ["tool_call_id", "name", "role"]
|
|
@@ -35,9 +45,13 @@ class ToolMessage(BaseModel):
|
|
|
35
45
|
for n, f in self.model_fields.items():
|
|
36
46
|
k = f.alias or n
|
|
37
47
|
val = serialized.get(k)
|
|
48
|
+
serialized.pop(k, None)
|
|
38
49
|
|
|
39
50
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
40
|
-
is_set = (
|
|
51
|
+
is_set = (
|
|
52
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
53
|
+
or k in null_default_fields
|
|
54
|
+
) # pylint: disable=no-member
|
|
41
55
|
|
|
42
56
|
if val is not None and val != UNSET_SENTINEL:
|
|
43
57
|
m[k] = val
|
|
@@ -47,4 +61,3 @@ class ToolMessage(BaseModel):
|
|
|
47
61
|
m[k] = val
|
|
48
62
|
|
|
49
63
|
return m
|
|
50
|
-
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai_azure.types import BaseModel
|
|
5
|
-
from
|
|
5
|
+
from typing_extensions import TypedDict
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class UsageInfoTypedDict(TypedDict):
|
|
9
9
|
prompt_tokens: int
|
|
10
10
|
completion_tokens: int
|
|
11
11
|
total_tokens: int
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
|
|
14
14
|
class UsageInfo(BaseModel):
|
|
15
15
|
prompt_tokens: int
|
|
16
|
+
|
|
16
17
|
completion_tokens: int
|
|
18
|
+
|
|
17
19
|
total_tokens: int
|
|
18
|
-
|
|
@@ -1,26 +1,58 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from .
|
|
5
|
-
from mistralai_azure.types import BaseModel
|
|
6
|
-
from
|
|
7
|
-
from
|
|
4
|
+
from .contentchunk import ContentChunk, ContentChunkTypedDict
|
|
5
|
+
from mistralai_azure.types import BaseModel, Nullable, UNSET_SENTINEL
|
|
6
|
+
from pydantic import model_serializer
|
|
7
|
+
from typing import List, Literal, Optional, Union
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
UserMessageContentTypedDict = Union[str, List[
|
|
11
|
+
UserMessageContentTypedDict = Union[str, List[ContentChunkTypedDict]]
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
UserMessageContent = Union[str, List[
|
|
14
|
+
UserMessageContent = Union[str, List[ContentChunk]]
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
UserMessageRole = Literal["user"]
|
|
17
18
|
|
|
19
|
+
|
|
18
20
|
class UserMessageTypedDict(TypedDict):
|
|
19
|
-
content: UserMessageContentTypedDict
|
|
21
|
+
content: Nullable[UserMessageContentTypedDict]
|
|
20
22
|
role: NotRequired[UserMessageRole]
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
class UserMessage(BaseModel):
|
|
24
|
-
content: UserMessageContent
|
|
26
|
+
content: Nullable[UserMessageContent]
|
|
27
|
+
|
|
25
28
|
role: Optional[UserMessageRole] = "user"
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
@model_serializer(mode="wrap")
|
|
31
|
+
def serialize_model(self, handler):
|
|
32
|
+
optional_fields = ["role"]
|
|
33
|
+
nullable_fields = ["content"]
|
|
34
|
+
null_default_fields = []
|
|
35
|
+
|
|
36
|
+
serialized = handler(self)
|
|
37
|
+
|
|
38
|
+
m = {}
|
|
39
|
+
|
|
40
|
+
for n, f in self.model_fields.items():
|
|
41
|
+
k = f.alias or n
|
|
42
|
+
val = serialized.get(k)
|
|
43
|
+
serialized.pop(k, None)
|
|
44
|
+
|
|
45
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
46
|
+
is_set = (
|
|
47
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
48
|
+
or k in null_default_fields
|
|
49
|
+
) # pylint: disable=no-member
|
|
50
|
+
|
|
51
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
52
|
+
m[k] = val
|
|
53
|
+
elif val != UNSET_SENTINEL and (
|
|
54
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
55
|
+
):
|
|
56
|
+
m[k] = val
|
|
57
|
+
|
|
58
|
+
return m
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai_azure.types import BaseModel
|
|
5
|
-
from typing import List,
|
|
5
|
+
from typing import List, Union
|
|
6
|
+
from typing_extensions import TypedDict
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
LocTypedDict = Union[str, int]
|
|
@@ -15,10 +16,11 @@ class ValidationErrorTypedDict(TypedDict):
|
|
|
15
16
|
loc: List[LocTypedDict]
|
|
16
17
|
msg: str
|
|
17
18
|
type: str
|
|
18
|
-
|
|
19
|
+
|
|
19
20
|
|
|
20
21
|
class ValidationError(BaseModel):
|
|
21
22
|
loc: List[Loc]
|
|
23
|
+
|
|
22
24
|
msg: str
|
|
25
|
+
|
|
23
26
|
type: str
|
|
24
|
-
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
from ._hooks import SDKHooks
|
|
5
4
|
from .httpclient import AsyncHttpClient, HttpClient
|
|
6
5
|
from .utils import Logger, RetryConfig, remove_suffix
|
|
@@ -11,10 +10,10 @@ from pydantic import Field
|
|
|
11
10
|
from typing import Callable, Dict, Optional, Tuple, Union
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
r"""Production server"""
|
|
13
|
+
SERVER_EU = "eu"
|
|
14
|
+
r"""EU Production server"""
|
|
16
15
|
SERVERS = {
|
|
17
|
-
|
|
16
|
+
SERVER_EU: "https://api.mistral.ai",
|
|
18
17
|
}
|
|
19
18
|
"""Contains the list of servers available to the SDK"""
|
|
20
19
|
|
|
@@ -24,14 +23,14 @@ class SDKConfiguration:
|
|
|
24
23
|
client: HttpClient
|
|
25
24
|
async_client: AsyncHttpClient
|
|
26
25
|
debug_logger: Logger
|
|
27
|
-
security: Optional[Union[models.Security,Callable[[], models.Security]]] = None
|
|
26
|
+
security: Optional[Union[models.Security, Callable[[], models.Security]]] = None
|
|
28
27
|
server_url: Optional[str] = ""
|
|
29
28
|
server: Optional[str] = ""
|
|
30
29
|
language: str = "python"
|
|
31
30
|
openapi_doc_version: str = "0.0.2"
|
|
32
|
-
sdk_version: str = "1.0
|
|
33
|
-
gen_version: str = "2.
|
|
34
|
-
user_agent: str = "speakeasy-sdk/python 1.0
|
|
31
|
+
sdk_version: str = "1.2.0"
|
|
32
|
+
gen_version: str = "2.452.0"
|
|
33
|
+
user_agent: str = "speakeasy-sdk/python 1.2.0 2.452.0 0.0.2 mistralai_azure"
|
|
35
34
|
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
|
36
35
|
timeout_ms: Optional[int] = None
|
|
37
36
|
|
|
@@ -42,13 +41,12 @@ class SDKConfiguration:
|
|
|
42
41
|
if self.server_url is not None and self.server_url:
|
|
43
42
|
return remove_suffix(self.server_url, "/"), {}
|
|
44
43
|
if not self.server:
|
|
45
|
-
self.server =
|
|
44
|
+
self.server = SERVER_EU
|
|
46
45
|
|
|
47
46
|
if self.server not in SERVERS:
|
|
48
|
-
raise ValueError(f
|
|
47
|
+
raise ValueError(f'Invalid server "{self.server}"')
|
|
49
48
|
|
|
50
49
|
return SERVERS[self.server], {}
|
|
51
50
|
|
|
52
|
-
|
|
53
51
|
def get_hooks(self) -> SDKHooks:
|
|
54
52
|
return self._hooks
|
|
@@ -27,14 +27,23 @@ from .serializers import (
|
|
|
27
27
|
serialize_float,
|
|
28
28
|
serialize_int,
|
|
29
29
|
stream_to_text,
|
|
30
|
+
stream_to_text_async,
|
|
31
|
+
stream_to_bytes,
|
|
32
|
+
stream_to_bytes_async,
|
|
33
|
+
validate_const,
|
|
30
34
|
validate_decimal,
|
|
31
35
|
validate_float,
|
|
32
36
|
validate_int,
|
|
33
37
|
validate_open_enum,
|
|
34
38
|
)
|
|
35
39
|
from .url import generate_url, template_url, remove_suffix
|
|
36
|
-
from .values import
|
|
37
|
-
|
|
40
|
+
from .values import (
|
|
41
|
+
get_global_from_env,
|
|
42
|
+
match_content_type,
|
|
43
|
+
match_status_codes,
|
|
44
|
+
match_response,
|
|
45
|
+
)
|
|
46
|
+
from .logger import Logger, get_body_content, get_default_logger
|
|
38
47
|
|
|
39
48
|
__all__ = [
|
|
40
49
|
"BackoffStrategy",
|
|
@@ -43,6 +52,7 @@ __all__ = [
|
|
|
43
52
|
"FormMetadata",
|
|
44
53
|
"generate_url",
|
|
45
54
|
"get_body_content",
|
|
55
|
+
"get_default_logger",
|
|
46
56
|
"get_discriminator",
|
|
47
57
|
"get_global_from_env",
|
|
48
58
|
"get_headers",
|
|
@@ -57,7 +67,6 @@ __all__ = [
|
|
|
57
67
|
"match_status_codes",
|
|
58
68
|
"match_response",
|
|
59
69
|
"MultipartFormMetadata",
|
|
60
|
-
"NoOpLogger",
|
|
61
70
|
"OpenEnumMeta",
|
|
62
71
|
"PathParamMetadata",
|
|
63
72
|
"QueryParamMetadata",
|
|
@@ -74,10 +83,14 @@ __all__ = [
|
|
|
74
83
|
"serialize_request_body",
|
|
75
84
|
"SerializedRequestBody",
|
|
76
85
|
"stream_to_text",
|
|
86
|
+
"stream_to_text_async",
|
|
87
|
+
"stream_to_bytes",
|
|
88
|
+
"stream_to_bytes_async",
|
|
77
89
|
"template_url",
|
|
78
90
|
"unmarshal",
|
|
79
91
|
"unmarshal_json",
|
|
80
92
|
"validate_decimal",
|
|
93
|
+
"validate_const",
|
|
81
94
|
"validate_float",
|
|
82
95
|
"validate_int",
|
|
83
96
|
"validate_open_enum",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
+
from enum import Enum
|
|
3
4
|
from typing import Any
|
|
4
5
|
|
|
5
6
|
def get_discriminator(model: Any, fieldname: str, key: str) -> str:
|
|
@@ -10,10 +11,20 @@ def get_discriminator(model: Any, fieldname: str, key: str) -> str:
|
|
|
10
11
|
raise ValueError(f'Could not find discriminator key {key} in {model}') from e
|
|
11
12
|
|
|
12
13
|
if hasattr(model, fieldname):
|
|
13
|
-
|
|
14
|
+
attr = getattr(model, fieldname)
|
|
15
|
+
|
|
16
|
+
if isinstance(attr, Enum):
|
|
17
|
+
return f'{attr.value}'
|
|
18
|
+
|
|
19
|
+
return f'{attr}'
|
|
14
20
|
|
|
15
21
|
fieldname = fieldname.upper()
|
|
16
22
|
if hasattr(model, fieldname):
|
|
17
|
-
|
|
23
|
+
attr = getattr(model, fieldname)
|
|
24
|
+
|
|
25
|
+
if isinstance(attr, Enum):
|
|
26
|
+
return f'{attr.value}'
|
|
27
|
+
|
|
28
|
+
return f'{attr}'
|
|
18
29
|
|
|
19
30
|
raise ValueError(f'Could not find discriminator field {fieldname} in {model}')
|
mistralai_azure/utils/forms.py
CHANGED
|
@@ -17,7 +17,7 @@ from .metadata import (
|
|
|
17
17
|
MultipartFormMetadata,
|
|
18
18
|
find_field_metadata,
|
|
19
19
|
)
|
|
20
|
-
from .values import _val_to_string
|
|
20
|
+
from .values import _is_set, _val_to_string
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def _populate_form(
|
|
@@ -27,7 +27,7 @@ def _populate_form(
|
|
|
27
27
|
delimiter: str,
|
|
28
28
|
form: Dict[str, List[str]],
|
|
29
29
|
):
|
|
30
|
-
if obj
|
|
30
|
+
if not _is_set(obj):
|
|
31
31
|
return form
|
|
32
32
|
|
|
33
33
|
if isinstance(obj, BaseModel):
|
|
@@ -41,7 +41,7 @@ def _populate_form(
|
|
|
41
41
|
continue
|
|
42
42
|
|
|
43
43
|
val = getattr(obj, name)
|
|
44
|
-
if val
|
|
44
|
+
if not _is_set(val):
|
|
45
45
|
continue
|
|
46
46
|
|
|
47
47
|
if explode:
|
|
@@ -54,7 +54,7 @@ def _populate_form(
|
|
|
54
54
|
elif isinstance(obj, Dict):
|
|
55
55
|
items = []
|
|
56
56
|
for key, value in obj.items():
|
|
57
|
-
if value
|
|
57
|
+
if not _is_set(value):
|
|
58
58
|
continue
|
|
59
59
|
|
|
60
60
|
if explode:
|
|
@@ -68,7 +68,7 @@ def _populate_form(
|
|
|
68
68
|
items = []
|
|
69
69
|
|
|
70
70
|
for value in obj:
|
|
71
|
-
if value
|
|
71
|
+
if not _is_set(value):
|
|
72
72
|
continue
|
|
73
73
|
|
|
74
74
|
if explode:
|
|
@@ -102,7 +102,7 @@ def serialize_multipart_form(
|
|
|
102
102
|
field = request_fields[name]
|
|
103
103
|
|
|
104
104
|
val = getattr(request, name)
|
|
105
|
-
if val
|
|
105
|
+
if not _is_set(val):
|
|
106
106
|
continue
|
|
107
107
|
|
|
108
108
|
field_metadata = find_field_metadata(field, MultipartFormMetadata)
|
|
@@ -156,7 +156,7 @@ def serialize_multipart_form(
|
|
|
156
156
|
values = []
|
|
157
157
|
|
|
158
158
|
for value in val:
|
|
159
|
-
if value
|
|
159
|
+
if not _is_set(value):
|
|
160
160
|
continue
|
|
161
161
|
values.append(_val_to_string(value))
|
|
162
162
|
|
|
@@ -176,7 +176,7 @@ def serialize_form_data(data: Any) -> Dict[str, Any]:
|
|
|
176
176
|
field = data_fields[name]
|
|
177
177
|
|
|
178
178
|
val = getattr(data, name)
|
|
179
|
-
if val
|
|
179
|
+
if not _is_set(val):
|
|
180
180
|
continue
|
|
181
181
|
|
|
182
182
|
metadata = find_field_metadata(field, FormMetadata)
|
|
@@ -200,7 +200,8 @@ def serialize_form_data(data: Any) -> Dict[str, Any]:
|
|
|
200
200
|
raise ValueError(f"Invalid form style for field {name}")
|
|
201
201
|
elif isinstance(data, Dict):
|
|
202
202
|
for key, value in data.items():
|
|
203
|
-
|
|
203
|
+
if _is_set(value):
|
|
204
|
+
form[key] = [_val_to_string(value)]
|
|
204
205
|
else:
|
|
205
206
|
raise TypeError(f"Invalid request body type {type(data)} for form data")
|
|
206
207
|
|
mistralai_azure/utils/headers.py
CHANGED
|
@@ -15,16 +15,16 @@ from .metadata import (
|
|
|
15
15
|
find_field_metadata,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
from .values import _populate_from_globals, _val_to_string
|
|
18
|
+
from .values import _is_set, _populate_from_globals, _val_to_string
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def get_headers(headers_params: Any, gbls: Optional[Any] = None) -> Dict[str, str]:
|
|
22
22
|
headers: Dict[str, str] = {}
|
|
23
23
|
|
|
24
24
|
globals_already_populated = []
|
|
25
|
-
if headers_params
|
|
25
|
+
if _is_set(headers_params):
|
|
26
26
|
globals_already_populated = _populate_headers(headers_params, gbls, headers, [])
|
|
27
|
-
if gbls
|
|
27
|
+
if _is_set(gbls):
|
|
28
28
|
_populate_headers(gbls, None, headers, globals_already_populated)
|
|
29
29
|
|
|
30
30
|
return headers
|
|
@@ -67,7 +67,7 @@ def _populate_headers(
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
def _serialize_header(explode: bool, obj: Any) -> str:
|
|
70
|
-
if obj
|
|
70
|
+
if not _is_set(obj):
|
|
71
71
|
return ""
|
|
72
72
|
|
|
73
73
|
if isinstance(obj, BaseModel):
|
|
@@ -83,7 +83,7 @@ def _serialize_header(explode: bool, obj: Any) -> str:
|
|
|
83
83
|
f_name = obj_field.alias if obj_field.alias is not None else name
|
|
84
84
|
|
|
85
85
|
val = getattr(obj, name)
|
|
86
|
-
if val
|
|
86
|
+
if not _is_set(val):
|
|
87
87
|
continue
|
|
88
88
|
|
|
89
89
|
if explode:
|
|
@@ -98,7 +98,7 @@ def _serialize_header(explode: bool, obj: Any) -> str:
|
|
|
98
98
|
items = []
|
|
99
99
|
|
|
100
100
|
for key, value in obj.items():
|
|
101
|
-
if value
|
|
101
|
+
if not _is_set(value):
|
|
102
102
|
continue
|
|
103
103
|
|
|
104
104
|
if explode:
|
|
@@ -113,14 +113,14 @@ def _serialize_header(explode: bool, obj: Any) -> str:
|
|
|
113
113
|
items = []
|
|
114
114
|
|
|
115
115
|
for value in obj:
|
|
116
|
-
if value
|
|
116
|
+
if not _is_set(value):
|
|
117
117
|
continue
|
|
118
118
|
|
|
119
119
|
items.append(_val_to_string(value))
|
|
120
120
|
|
|
121
121
|
if len(items) > 0:
|
|
122
122
|
return ",".join(items)
|
|
123
|
-
|
|
123
|
+
elif _is_set(obj):
|
|
124
124
|
return f"{_val_to_string(obj)}"
|
|
125
125
|
|
|
126
126
|
return ""
|
mistralai_azure/utils/logger.py
CHANGED
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
import httpx
|
|
4
4
|
from typing import Any, Protocol
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
class Logger(Protocol):
|
|
7
8
|
def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
8
9
|
pass
|
|
9
10
|
|
|
11
|
+
|
|
10
12
|
class NoOpLogger:
|
|
11
13
|
def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
12
14
|
pass
|
|
13
15
|
|
|
16
|
+
|
|
14
17
|
def get_body_content(req: httpx.Request) -> str:
|
|
15
18
|
return "<streaming body>" if not hasattr(req, "_content") else str(req.content)
|
|
16
19
|
|
|
20
|
+
|
|
21
|
+
def get_default_logger() -> Logger:
|
|
22
|
+
return NoOpLogger()
|
|
@@ -15,7 +15,12 @@ from .metadata import (
|
|
|
15
15
|
QueryParamMetadata,
|
|
16
16
|
find_field_metadata,
|
|
17
17
|
)
|
|
18
|
-
from .values import
|
|
18
|
+
from .values import (
|
|
19
|
+
_get_serialized_params,
|
|
20
|
+
_is_set,
|
|
21
|
+
_populate_from_globals,
|
|
22
|
+
_val_to_string,
|
|
23
|
+
)
|
|
19
24
|
from .forms import _populate_form
|
|
20
25
|
|
|
21
26
|
|
|
@@ -26,7 +31,7 @@ def get_query_params(
|
|
|
26
31
|
params: Dict[str, List[str]] = {}
|
|
27
32
|
|
|
28
33
|
globals_already_populated = _populate_query_params(query_params, gbls, params, [])
|
|
29
|
-
if gbls
|
|
34
|
+
if _is_set(gbls):
|
|
30
35
|
_populate_query_params(gbls, None, params, globals_already_populated)
|
|
31
36
|
|
|
32
37
|
return params
|
|
@@ -55,7 +60,7 @@ def _populate_query_params(
|
|
|
55
60
|
if not metadata:
|
|
56
61
|
continue
|
|
57
62
|
|
|
58
|
-
value = getattr(query_params, name) if query_params
|
|
63
|
+
value = getattr(query_params, name) if _is_set(query_params) else None
|
|
59
64
|
|
|
60
65
|
value, global_found = _populate_from_globals(
|
|
61
66
|
name, value, QueryParamMetadata, gbls
|
|
@@ -99,7 +104,7 @@ def _populate_deep_object_query_params(
|
|
|
99
104
|
obj: Any,
|
|
100
105
|
params: Dict[str, List[str]],
|
|
101
106
|
):
|
|
102
|
-
if obj
|
|
107
|
+
if not _is_set(obj):
|
|
103
108
|
return
|
|
104
109
|
|
|
105
110
|
if isinstance(obj, BaseModel):
|
|
@@ -113,10 +118,7 @@ def _populate_deep_object_query_params_basemodel(
|
|
|
113
118
|
obj: Any,
|
|
114
119
|
params: Dict[str, List[str]],
|
|
115
120
|
):
|
|
116
|
-
if obj
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
if not isinstance(obj, BaseModel):
|
|
121
|
+
if not _is_set(obj) or not isinstance(obj, BaseModel):
|
|
120
122
|
return
|
|
121
123
|
|
|
122
124
|
obj_fields: Dict[str, FieldInfo] = obj.__class__.model_fields
|
|
@@ -128,11 +130,11 @@ def _populate_deep_object_query_params_basemodel(
|
|
|
128
130
|
params_key = f"{prior_params_key}[{f_name}]"
|
|
129
131
|
|
|
130
132
|
obj_param_metadata = find_field_metadata(obj_field, QueryParamMetadata)
|
|
131
|
-
if obj_param_metadata
|
|
133
|
+
if not _is_set(obj_param_metadata):
|
|
132
134
|
continue
|
|
133
135
|
|
|
134
136
|
obj_val = getattr(obj, name)
|
|
135
|
-
if obj_val
|
|
137
|
+
if not _is_set(obj_val):
|
|
136
138
|
continue
|
|
137
139
|
|
|
138
140
|
if isinstance(obj_val, BaseModel):
|
|
@@ -150,11 +152,11 @@ def _populate_deep_object_query_params_dict(
|
|
|
150
152
|
value: Dict,
|
|
151
153
|
params: Dict[str, List[str]],
|
|
152
154
|
):
|
|
153
|
-
if value
|
|
155
|
+
if not _is_set(value):
|
|
154
156
|
return
|
|
155
157
|
|
|
156
158
|
for key, val in value.items():
|
|
157
|
-
if val
|
|
159
|
+
if not _is_set(val):
|
|
158
160
|
continue
|
|
159
161
|
|
|
160
162
|
params_key = f"{prior_params_key}[{key}]"
|
|
@@ -174,11 +176,11 @@ def _populate_deep_object_query_params_list(
|
|
|
174
176
|
value: List,
|
|
175
177
|
params: Dict[str, List[str]],
|
|
176
178
|
):
|
|
177
|
-
if value
|
|
179
|
+
if not _is_set(value):
|
|
178
180
|
return
|
|
179
181
|
|
|
180
182
|
for val in value:
|
|
181
|
-
if val
|
|
183
|
+
if not _is_set(val):
|
|
182
184
|
continue
|
|
183
185
|
|
|
184
186
|
if params.get(params_key) is None:
|
mistralai_azure/utils/retries.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
+
import asyncio
|
|
3
4
|
import random
|
|
4
5
|
import time
|
|
5
6
|
from typing import List
|
|
@@ -212,5 +213,5 @@ async def retry_with_backoff_async(
|
|
|
212
213
|
raise
|
|
213
214
|
sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
|
|
214
215
|
sleep = min(sleep, max_interval / 1000)
|
|
215
|
-
|
|
216
|
+
await asyncio.sleep(sleep)
|
|
216
217
|
retries += 1
|