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
|
@@ -9,13 +9,26 @@ from .jobmetadataout import JobMetadataOut, JobMetadataOutTypedDict
|
|
|
9
9
|
from .trainingparameters import TrainingParameters, TrainingParametersTypedDict
|
|
10
10
|
from .wandbintegrationout import WandbIntegrationOut, WandbIntegrationOutTypedDict
|
|
11
11
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
12
|
+
from mistralai.utils import validate_const
|
|
12
13
|
import pydantic
|
|
13
14
|
from pydantic import model_serializer
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
from pydantic.functional_validators import AfterValidator
|
|
16
|
+
from typing import List, Literal, Optional
|
|
17
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
DetailedJobOutStatus = Literal[
|
|
21
|
+
"QUEUED",
|
|
22
|
+
"STARTED",
|
|
23
|
+
"VALIDATING",
|
|
24
|
+
"VALIDATED",
|
|
25
|
+
"RUNNING",
|
|
26
|
+
"FAILED_VALIDATION",
|
|
27
|
+
"FAILED",
|
|
28
|
+
"SUCCESS",
|
|
29
|
+
"CANCELLED",
|
|
30
|
+
"CANCELLATION_REQUESTED",
|
|
31
|
+
]
|
|
19
32
|
|
|
20
33
|
DetailedJobOutObject = Literal["job"]
|
|
21
34
|
|
|
@@ -43,6 +56,7 @@ class DetailedJobOutTypedDict(TypedDict):
|
|
|
43
56
|
modified_at: int
|
|
44
57
|
training_files: List[str]
|
|
45
58
|
validation_files: NotRequired[Nullable[List[str]]]
|
|
59
|
+
object: DetailedJobOutObject
|
|
46
60
|
fine_tuned_model: NotRequired[Nullable[str]]
|
|
47
61
|
suffix: NotRequired[Nullable[str]]
|
|
48
62
|
integrations: NotRequired[Nullable[List[DetailedJobOutIntegrationsTypedDict]]]
|
|
@@ -52,35 +66,76 @@ class DetailedJobOutTypedDict(TypedDict):
|
|
|
52
66
|
events: NotRequired[List[EventOutTypedDict]]
|
|
53
67
|
r"""Event items are created every time the status of a fine-tuning job changes. The timestamped list of all events is accessible here."""
|
|
54
68
|
checkpoints: NotRequired[List[CheckpointOutTypedDict]]
|
|
55
|
-
|
|
69
|
+
|
|
56
70
|
|
|
57
71
|
class DetailedJobOut(BaseModel):
|
|
58
72
|
id: str
|
|
73
|
+
|
|
59
74
|
auto_start: bool
|
|
75
|
+
|
|
60
76
|
hyperparameters: TrainingParameters
|
|
77
|
+
|
|
61
78
|
model: FineTuneableModel
|
|
62
79
|
r"""The name of the model to fine-tune."""
|
|
80
|
+
|
|
63
81
|
status: DetailedJobOutStatus
|
|
82
|
+
|
|
64
83
|
job_type: str
|
|
84
|
+
|
|
65
85
|
created_at: int
|
|
86
|
+
|
|
66
87
|
modified_at: int
|
|
88
|
+
|
|
67
89
|
training_files: List[str]
|
|
90
|
+
|
|
68
91
|
validation_files: OptionalNullable[List[str]] = UNSET
|
|
69
|
-
|
|
92
|
+
|
|
93
|
+
OBJECT: Annotated[
|
|
94
|
+
Annotated[
|
|
95
|
+
Optional[DetailedJobOutObject], AfterValidator(validate_const("job"))
|
|
96
|
+
],
|
|
97
|
+
pydantic.Field(alias="object"),
|
|
98
|
+
] = "job"
|
|
99
|
+
|
|
70
100
|
fine_tuned_model: OptionalNullable[str] = UNSET
|
|
101
|
+
|
|
71
102
|
suffix: OptionalNullable[str] = UNSET
|
|
103
|
+
|
|
72
104
|
integrations: OptionalNullable[List[DetailedJobOutIntegrations]] = UNSET
|
|
105
|
+
|
|
73
106
|
trained_tokens: OptionalNullable[int] = UNSET
|
|
107
|
+
|
|
74
108
|
repositories: Optional[List[DetailedJobOutRepositories]] = None
|
|
109
|
+
|
|
75
110
|
metadata: OptionalNullable[JobMetadataOut] = UNSET
|
|
111
|
+
|
|
76
112
|
events: Optional[List[EventOut]] = None
|
|
77
113
|
r"""Event items are created every time the status of a fine-tuning job changes. The timestamped list of all events is accessible here."""
|
|
114
|
+
|
|
78
115
|
checkpoints: Optional[List[CheckpointOut]] = None
|
|
79
|
-
|
|
116
|
+
|
|
80
117
|
@model_serializer(mode="wrap")
|
|
81
118
|
def serialize_model(self, handler):
|
|
82
|
-
optional_fields = [
|
|
83
|
-
|
|
119
|
+
optional_fields = [
|
|
120
|
+
"validation_files",
|
|
121
|
+
"object",
|
|
122
|
+
"fine_tuned_model",
|
|
123
|
+
"suffix",
|
|
124
|
+
"integrations",
|
|
125
|
+
"trained_tokens",
|
|
126
|
+
"repositories",
|
|
127
|
+
"metadata",
|
|
128
|
+
"events",
|
|
129
|
+
"checkpoints",
|
|
130
|
+
]
|
|
131
|
+
nullable_fields = [
|
|
132
|
+
"validation_files",
|
|
133
|
+
"fine_tuned_model",
|
|
134
|
+
"suffix",
|
|
135
|
+
"integrations",
|
|
136
|
+
"trained_tokens",
|
|
137
|
+
"metadata",
|
|
138
|
+
]
|
|
84
139
|
null_default_fields = []
|
|
85
140
|
|
|
86
141
|
serialized = handler(self)
|
|
@@ -90,9 +145,13 @@ class DetailedJobOut(BaseModel):
|
|
|
90
145
|
for n, f in self.model_fields.items():
|
|
91
146
|
k = f.alias or n
|
|
92
147
|
val = serialized.get(k)
|
|
148
|
+
serialized.pop(k, None)
|
|
93
149
|
|
|
94
150
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
95
|
-
is_set = (
|
|
151
|
+
is_set = (
|
|
152
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
153
|
+
or k in null_default_fields
|
|
154
|
+
) # pylint: disable=no-member
|
|
96
155
|
|
|
97
156
|
if val is not None and val != UNSET_SENTINEL:
|
|
98
157
|
m[k] = val
|
|
@@ -102,4 +161,3 @@ class DetailedJobOut(BaseModel):
|
|
|
102
161
|
m[k] = val
|
|
103
162
|
|
|
104
163
|
return m
|
|
105
|
-
|
|
@@ -4,8 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
5
5
|
import pydantic
|
|
6
6
|
from pydantic import model_serializer
|
|
7
|
-
from typing import List,
|
|
8
|
-
from typing_extensions import Annotated, NotRequired
|
|
7
|
+
from typing import List, Optional, Union
|
|
8
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
InputsTypedDict = Union[str, List[str]]
|
|
@@ -19,23 +19,25 @@ r"""Text to embed."""
|
|
|
19
19
|
class EmbeddingRequestTypedDict(TypedDict):
|
|
20
20
|
inputs: InputsTypedDict
|
|
21
21
|
r"""Text to embed."""
|
|
22
|
-
model: str
|
|
22
|
+
model: NotRequired[str]
|
|
23
23
|
r"""ID of the model to use."""
|
|
24
24
|
encoding_format: NotRequired[Nullable[str]]
|
|
25
25
|
r"""The format to return the embeddings in."""
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
|
|
28
28
|
class EmbeddingRequest(BaseModel):
|
|
29
29
|
inputs: Annotated[Inputs, pydantic.Field(alias="input")]
|
|
30
30
|
r"""Text to embed."""
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
model: Optional[str] = "mistral-embed"
|
|
32
33
|
r"""ID of the model to use."""
|
|
34
|
+
|
|
33
35
|
encoding_format: OptionalNullable[str] = UNSET
|
|
34
36
|
r"""The format to return the embeddings in."""
|
|
35
|
-
|
|
37
|
+
|
|
36
38
|
@model_serializer(mode="wrap")
|
|
37
39
|
def serialize_model(self, handler):
|
|
38
|
-
optional_fields = ["encoding_format"]
|
|
40
|
+
optional_fields = ["model", "encoding_format"]
|
|
39
41
|
nullable_fields = ["encoding_format"]
|
|
40
42
|
null_default_fields = []
|
|
41
43
|
|
|
@@ -46,9 +48,13 @@ class EmbeddingRequest(BaseModel):
|
|
|
46
48
|
for n, f in self.model_fields.items():
|
|
47
49
|
k = f.alias or n
|
|
48
50
|
val = serialized.get(k)
|
|
51
|
+
serialized.pop(k, None)
|
|
49
52
|
|
|
50
53
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
51
|
-
is_set = (
|
|
54
|
+
is_set = (
|
|
55
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
56
|
+
or k in null_default_fields
|
|
57
|
+
) # pylint: disable=no-member
|
|
52
58
|
|
|
53
59
|
if val is not None and val != UNSET_SENTINEL:
|
|
54
60
|
m[k] = val
|
|
@@ -58,4 +64,3 @@ class EmbeddingRequest(BaseModel):
|
|
|
58
64
|
m[k] = val
|
|
59
65
|
|
|
60
66
|
return m
|
|
61
|
-
|
|
@@ -4,7 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
from .embeddingresponsedata import EmbeddingResponseData, EmbeddingResponseDataTypedDict
|
|
5
5
|
from .usageinfo import UsageInfo, UsageInfoTypedDict
|
|
6
6
|
from mistralai.types import BaseModel
|
|
7
|
-
from typing import List
|
|
7
|
+
from typing import List
|
|
8
|
+
from typing_extensions import TypedDict
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class EmbeddingResponseTypedDict(TypedDict):
|
|
@@ -13,12 +14,15 @@ class EmbeddingResponseTypedDict(TypedDict):
|
|
|
13
14
|
model: str
|
|
14
15
|
usage: UsageInfoTypedDict
|
|
15
16
|
data: List[EmbeddingResponseDataTypedDict]
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
|
|
18
19
|
class EmbeddingResponse(BaseModel):
|
|
19
20
|
id: str
|
|
21
|
+
|
|
20
22
|
object: str
|
|
23
|
+
|
|
21
24
|
model: str
|
|
25
|
+
|
|
22
26
|
usage: UsageInfo
|
|
27
|
+
|
|
23
28
|
data: List[EmbeddingResponseData]
|
|
24
|
-
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
|
-
from typing import List, Optional
|
|
6
|
-
from typing_extensions import NotRequired
|
|
5
|
+
from typing import List, Optional
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class EmbeddingResponseDataTypedDict(TypedDict):
|
|
10
10
|
object: NotRequired[str]
|
|
11
11
|
embedding: NotRequired[List[float]]
|
|
12
12
|
index: NotRequired[int]
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
|
|
15
15
|
class EmbeddingResponseData(BaseModel):
|
|
16
16
|
object: Optional[str] = None
|
|
17
|
+
|
|
17
18
|
embedding: Optional[List[float]] = None
|
|
19
|
+
|
|
18
20
|
index: Optional[int] = None
|
|
19
|
-
|
mistralai/models/eventout.py
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
5
5
|
from pydantic import model_serializer
|
|
6
|
-
from typing import Any, Dict
|
|
7
|
-
from typing_extensions import NotRequired
|
|
6
|
+
from typing import Any, Dict
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class EventOutTypedDict(TypedDict):
|
|
@@ -13,15 +13,17 @@ class EventOutTypedDict(TypedDict):
|
|
|
13
13
|
created_at: int
|
|
14
14
|
r"""The UNIX timestamp (in seconds) of the event."""
|
|
15
15
|
data: NotRequired[Nullable[Dict[str, Any]]]
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
|
|
18
18
|
class EventOut(BaseModel):
|
|
19
19
|
name: str
|
|
20
20
|
r"""The name of the event."""
|
|
21
|
+
|
|
21
22
|
created_at: int
|
|
22
23
|
r"""The UNIX timestamp (in seconds) of the event."""
|
|
24
|
+
|
|
23
25
|
data: OptionalNullable[Dict[str, Any]] = UNSET
|
|
24
|
-
|
|
26
|
+
|
|
25
27
|
@model_serializer(mode="wrap")
|
|
26
28
|
def serialize_model(self, handler):
|
|
27
29
|
optional_fields = ["data"]
|
|
@@ -35,9 +37,13 @@ class EventOut(BaseModel):
|
|
|
35
37
|
for n, f in self.model_fields.items():
|
|
36
38
|
k = f.alias or n
|
|
37
39
|
val = serialized.get(k)
|
|
40
|
+
serialized.pop(k, None)
|
|
38
41
|
|
|
39
42
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
40
|
-
is_set = (
|
|
43
|
+
is_set = (
|
|
44
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
45
|
+
or k in null_default_fields
|
|
46
|
+
) # pylint: disable=no-member
|
|
41
47
|
|
|
42
48
|
if val is not None and val != UNSET_SENTINEL:
|
|
43
49
|
m[k] = val
|
|
@@ -47,4 +53,3 @@ class EventOut(BaseModel):
|
|
|
47
53
|
m[k] = val
|
|
48
54
|
|
|
49
55
|
return m
|
|
50
|
-
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai.types import UnrecognizedStr
|
|
5
|
+
from typing import Literal, Union
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
FilePurpose = Union[Literal["fine-tune", "batch"], UnrecognizedStr]
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
5
|
from mistralai.utils import FieldMetadata, PathParamMetadata
|
|
6
|
-
from
|
|
7
|
-
from typing_extensions import Annotated
|
|
6
|
+
from typing_extensions import Annotated, TypedDict
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class FilesAPIRoutesDeleteFileRequestTypedDict(TypedDict):
|
|
11
10
|
file_id: str
|
|
12
|
-
|
|
11
|
+
|
|
13
12
|
|
|
14
13
|
class FilesAPIRoutesDeleteFileRequest(BaseModel):
|
|
15
|
-
file_id: Annotated[
|
|
16
|
-
|
|
14
|
+
file_id: Annotated[
|
|
15
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
16
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai.types import BaseModel
|
|
5
|
+
from mistralai.utils import FieldMetadata, PathParamMetadata
|
|
6
|
+
from typing_extensions import Annotated, TypedDict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class FilesAPIRoutesDownloadFileRequestTypedDict(TypedDict):
|
|
10
|
+
file_id: str
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class FilesAPIRoutesDownloadFileRequest(BaseModel):
|
|
14
|
+
file_id: Annotated[
|
|
15
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
16
|
+
]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .filepurpose import FilePurpose
|
|
5
|
+
from .sampletype import SampleType
|
|
6
|
+
from .source import Source
|
|
7
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
8
|
+
from mistralai.utils import FieldMetadata, QueryParamMetadata, validate_open_enum
|
|
9
|
+
from pydantic import model_serializer
|
|
10
|
+
from pydantic.functional_validators import PlainValidator
|
|
11
|
+
from typing import List, Optional
|
|
12
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FilesAPIRoutesListFilesRequestTypedDict(TypedDict):
|
|
16
|
+
page: NotRequired[int]
|
|
17
|
+
page_size: NotRequired[int]
|
|
18
|
+
sample_type: NotRequired[Nullable[List[SampleType]]]
|
|
19
|
+
source: NotRequired[Nullable[List[Source]]]
|
|
20
|
+
search: NotRequired[Nullable[str]]
|
|
21
|
+
purpose: NotRequired[Nullable[FilePurpose]]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class FilesAPIRoutesListFilesRequest(BaseModel):
|
|
25
|
+
page: Annotated[
|
|
26
|
+
Optional[int],
|
|
27
|
+
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
28
|
+
] = 0
|
|
29
|
+
|
|
30
|
+
page_size: Annotated[
|
|
31
|
+
Optional[int],
|
|
32
|
+
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
33
|
+
] = 100
|
|
34
|
+
|
|
35
|
+
sample_type: Annotated[
|
|
36
|
+
OptionalNullable[
|
|
37
|
+
List[Annotated[SampleType, PlainValidator(validate_open_enum(False))]]
|
|
38
|
+
],
|
|
39
|
+
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
40
|
+
] = UNSET
|
|
41
|
+
|
|
42
|
+
source: Annotated[
|
|
43
|
+
OptionalNullable[
|
|
44
|
+
List[Annotated[Source, PlainValidator(validate_open_enum(False))]]
|
|
45
|
+
],
|
|
46
|
+
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
47
|
+
] = UNSET
|
|
48
|
+
|
|
49
|
+
search: Annotated[
|
|
50
|
+
OptionalNullable[str],
|
|
51
|
+
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
52
|
+
] = UNSET
|
|
53
|
+
|
|
54
|
+
purpose: Annotated[
|
|
55
|
+
Annotated[
|
|
56
|
+
OptionalNullable[FilePurpose], PlainValidator(validate_open_enum(False))
|
|
57
|
+
],
|
|
58
|
+
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
|
|
59
|
+
] = UNSET
|
|
60
|
+
|
|
61
|
+
@model_serializer(mode="wrap")
|
|
62
|
+
def serialize_model(self, handler):
|
|
63
|
+
optional_fields = [
|
|
64
|
+
"page",
|
|
65
|
+
"page_size",
|
|
66
|
+
"sample_type",
|
|
67
|
+
"source",
|
|
68
|
+
"search",
|
|
69
|
+
"purpose",
|
|
70
|
+
]
|
|
71
|
+
nullable_fields = ["sample_type", "source", "search", "purpose"]
|
|
72
|
+
null_default_fields = []
|
|
73
|
+
|
|
74
|
+
serialized = handler(self)
|
|
75
|
+
|
|
76
|
+
m = {}
|
|
77
|
+
|
|
78
|
+
for n, f in self.model_fields.items():
|
|
79
|
+
k = f.alias or n
|
|
80
|
+
val = serialized.get(k)
|
|
81
|
+
serialized.pop(k, None)
|
|
82
|
+
|
|
83
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
84
|
+
is_set = (
|
|
85
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
86
|
+
or k in null_default_fields
|
|
87
|
+
) # pylint: disable=no-member
|
|
88
|
+
|
|
89
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
90
|
+
m[k] = val
|
|
91
|
+
elif val != UNSET_SENTINEL and (
|
|
92
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
93
|
+
):
|
|
94
|
+
m[k] = val
|
|
95
|
+
|
|
96
|
+
return m
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
5
|
from mistralai.utils import FieldMetadata, PathParamMetadata
|
|
6
|
-
from
|
|
7
|
-
from typing_extensions import Annotated
|
|
6
|
+
from typing_extensions import Annotated, TypedDict
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class FilesAPIRoutesRetrieveFileRequestTypedDict(TypedDict):
|
|
11
10
|
file_id: str
|
|
12
|
-
|
|
11
|
+
|
|
13
12
|
|
|
14
13
|
class FilesAPIRoutesRetrieveFileRequest(BaseModel):
|
|
15
|
-
file_id: Annotated[
|
|
16
|
-
|
|
14
|
+
file_id: Annotated[
|
|
15
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
16
|
+
]
|
|
@@ -1,28 +1,39 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
+
from .filepurpose import FilePurpose
|
|
4
5
|
import io
|
|
5
|
-
from mistralai.types import BaseModel
|
|
6
|
+
from mistralai.types import BaseModel
|
|
6
7
|
from mistralai.utils import FieldMetadata, MultipartFormMetadata, validate_open_enum
|
|
7
8
|
import pydantic
|
|
8
9
|
from pydantic.functional_validators import PlainValidator
|
|
9
|
-
from typing import
|
|
10
|
-
from typing_extensions import Annotated, NotRequired
|
|
10
|
+
from typing import IO, Optional, Union
|
|
11
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
FilesAPIRoutesUploadFilePurpose = Union[Literal["fine-tune"], UnrecognizedStr]
|
|
14
|
-
|
|
15
14
|
class FileTypedDict(TypedDict):
|
|
16
15
|
file_name: str
|
|
17
16
|
content: Union[bytes, IO[bytes], io.BufferedReader]
|
|
18
17
|
content_type: NotRequired[str]
|
|
19
|
-
|
|
18
|
+
|
|
20
19
|
|
|
21
20
|
class File(BaseModel):
|
|
22
|
-
file_name: Annotated[
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
file_name: Annotated[
|
|
22
|
+
str, pydantic.Field(alias="file"), FieldMetadata(multipart=True)
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
content: Annotated[
|
|
26
|
+
Union[bytes, IO[bytes], io.BufferedReader],
|
|
27
|
+
pydantic.Field(alias=""),
|
|
28
|
+
FieldMetadata(multipart=MultipartFormMetadata(content=True)),
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
content_type: Annotated[
|
|
32
|
+
Optional[str],
|
|
33
|
+
pydantic.Field(alias="Content-Type"),
|
|
34
|
+
FieldMetadata(multipart=True),
|
|
35
|
+
] = None
|
|
36
|
+
|
|
26
37
|
|
|
27
38
|
class FilesAPIRoutesUploadFileMultiPartBodyParamsTypedDict(TypedDict):
|
|
28
39
|
file: FileTypedDict
|
|
@@ -36,10 +47,15 @@ class FilesAPIRoutesUploadFileMultiPartBodyParamsTypedDict(TypedDict):
|
|
|
36
47
|
file=@path/to/your/file.jsonl
|
|
37
48
|
```
|
|
38
49
|
"""
|
|
39
|
-
|
|
50
|
+
purpose: NotRequired[FilePurpose]
|
|
51
|
+
|
|
40
52
|
|
|
41
53
|
class FilesAPIRoutesUploadFileMultiPartBodyParams(BaseModel):
|
|
42
|
-
file: Annotated[
|
|
54
|
+
file: Annotated[
|
|
55
|
+
File,
|
|
56
|
+
pydantic.Field(alias=""),
|
|
57
|
+
FieldMetadata(multipart=MultipartFormMetadata(file=True)),
|
|
58
|
+
]
|
|
43
59
|
r"""The File object (not file name) to be uploaded.
|
|
44
60
|
To upload a file and specify a custom file name you should format your request as such:
|
|
45
61
|
```bash
|
|
@@ -50,5 +66,8 @@ class FilesAPIRoutesUploadFileMultiPartBodyParams(BaseModel):
|
|
|
50
66
|
file=@path/to/your/file.jsonl
|
|
51
67
|
```
|
|
52
68
|
"""
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
|
|
70
|
+
purpose: Annotated[
|
|
71
|
+
Annotated[Optional[FilePurpose], PlainValidator(validate_open_enum(False))],
|
|
72
|
+
FieldMetadata(multipart=True),
|
|
73
|
+
] = None
|
mistralai/models/fileschema.py
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
+
from .filepurpose import FilePurpose
|
|
4
5
|
from .sampletype import SampleType
|
|
5
6
|
from .source import Source
|
|
6
|
-
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
7
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
7
8
|
from mistralai.utils import validate_open_enum
|
|
8
|
-
import pydantic
|
|
9
9
|
from pydantic import model_serializer
|
|
10
10
|
from pydantic.functional_validators import PlainValidator
|
|
11
|
-
from
|
|
12
|
-
from typing_extensions import Annotated, NotRequired
|
|
11
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
13
12
|
|
|
14
13
|
|
|
15
|
-
FileSchemaPurpose = Union[Literal["fine-tune"], UnrecognizedStr]
|
|
16
|
-
r"""The intended purpose of the uploaded file. Only accepts fine-tuning (`fine-tune`) for now."""
|
|
17
|
-
|
|
18
14
|
class FileSchemaTypedDict(TypedDict):
|
|
19
15
|
id: str
|
|
20
16
|
r"""The unique identifier of the file."""
|
|
@@ -26,28 +22,36 @@ class FileSchemaTypedDict(TypedDict):
|
|
|
26
22
|
r"""The UNIX timestamp (in seconds) of the event."""
|
|
27
23
|
filename: str
|
|
28
24
|
r"""The name of the uploaded file."""
|
|
25
|
+
purpose: FilePurpose
|
|
29
26
|
sample_type: SampleType
|
|
30
27
|
source: Source
|
|
31
28
|
num_lines: NotRequired[Nullable[int]]
|
|
32
|
-
|
|
29
|
+
|
|
33
30
|
|
|
34
31
|
class FileSchema(BaseModel):
|
|
35
32
|
id: str
|
|
36
33
|
r"""The unique identifier of the file."""
|
|
34
|
+
|
|
37
35
|
object: str
|
|
38
36
|
r"""The object type, which is always \"file\"."""
|
|
37
|
+
|
|
39
38
|
bytes: int
|
|
40
39
|
r"""The size of the file, in bytes."""
|
|
40
|
+
|
|
41
41
|
created_at: int
|
|
42
42
|
r"""The UNIX timestamp (in seconds) of the event."""
|
|
43
|
+
|
|
43
44
|
filename: str
|
|
44
45
|
r"""The name of the uploaded file."""
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
|
|
47
|
+
purpose: Annotated[FilePurpose, PlainValidator(validate_open_enum(False))]
|
|
48
|
+
|
|
49
|
+
sample_type: Annotated[SampleType, PlainValidator(validate_open_enum(False))]
|
|
50
|
+
|
|
51
|
+
source: Annotated[Source, PlainValidator(validate_open_enum(False))]
|
|
52
|
+
|
|
49
53
|
num_lines: OptionalNullable[int] = UNSET
|
|
50
|
-
|
|
54
|
+
|
|
51
55
|
@model_serializer(mode="wrap")
|
|
52
56
|
def serialize_model(self, handler):
|
|
53
57
|
optional_fields = ["num_lines"]
|
|
@@ -61,9 +65,13 @@ class FileSchema(BaseModel):
|
|
|
61
65
|
for n, f in self.model_fields.items():
|
|
62
66
|
k = f.alias or n
|
|
63
67
|
val = serialized.get(k)
|
|
68
|
+
serialized.pop(k, None)
|
|
64
69
|
|
|
65
70
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
66
|
-
is_set = (
|
|
71
|
+
is_set = (
|
|
72
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
73
|
+
or k in null_default_fields
|
|
74
|
+
) # pylint: disable=no-member
|
|
67
75
|
|
|
68
76
|
if val is not None and val != UNSET_SENTINEL:
|
|
69
77
|
m[k] = val
|
|
@@ -73,4 +81,3 @@ class FileSchema(BaseModel):
|
|
|
73
81
|
m[k] = val
|
|
74
82
|
|
|
75
83
|
return m
|
|
76
|
-
|