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
|
@@ -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
|
-
RetrieveFileOutPurpose = 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 RetrieveFileOutTypedDict(TypedDict):
|
|
19
15
|
id: str
|
|
20
16
|
r"""The unique identifier of the file."""
|
|
@@ -26,28 +22,39 @@ class RetrieveFileOutTypedDict(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
|
|
28
|
+
deleted: bool
|
|
31
29
|
num_lines: NotRequired[Nullable[int]]
|
|
32
|
-
|
|
30
|
+
|
|
33
31
|
|
|
34
32
|
class RetrieveFileOut(BaseModel):
|
|
35
33
|
id: str
|
|
36
34
|
r"""The unique identifier of the file."""
|
|
35
|
+
|
|
37
36
|
object: str
|
|
38
37
|
r"""The object type, which is always \"file\"."""
|
|
38
|
+
|
|
39
39
|
bytes: int
|
|
40
40
|
r"""The size of the file, in bytes."""
|
|
41
|
+
|
|
41
42
|
created_at: int
|
|
42
43
|
r"""The UNIX timestamp (in seconds) of the event."""
|
|
44
|
+
|
|
43
45
|
filename: str
|
|
44
46
|
r"""The name of the uploaded file."""
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
|
|
48
|
+
purpose: Annotated[FilePurpose, PlainValidator(validate_open_enum(False))]
|
|
49
|
+
|
|
50
|
+
sample_type: Annotated[SampleType, PlainValidator(validate_open_enum(False))]
|
|
51
|
+
|
|
52
|
+
source: Annotated[Source, PlainValidator(validate_open_enum(False))]
|
|
53
|
+
|
|
54
|
+
deleted: bool
|
|
55
|
+
|
|
49
56
|
num_lines: OptionalNullable[int] = UNSET
|
|
50
|
-
|
|
57
|
+
|
|
51
58
|
@model_serializer(mode="wrap")
|
|
52
59
|
def serialize_model(self, handler):
|
|
53
60
|
optional_fields = ["num_lines"]
|
|
@@ -61,9 +68,13 @@ class RetrieveFileOut(BaseModel):
|
|
|
61
68
|
for n, f in self.model_fields.items():
|
|
62
69
|
k = f.alias or n
|
|
63
70
|
val = serialized.get(k)
|
|
71
|
+
serialized.pop(k, None)
|
|
64
72
|
|
|
65
73
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
66
|
-
is_set = (
|
|
74
|
+
is_set = (
|
|
75
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
76
|
+
or k in null_default_fields
|
|
77
|
+
) # pylint: disable=no-member
|
|
67
78
|
|
|
68
79
|
if val is not None and val != UNSET_SENTINEL:
|
|
69
80
|
m[k] = val
|
|
@@ -73,4 +84,3 @@ class RetrieveFileOut(BaseModel):
|
|
|
73
84
|
m[k] = val
|
|
74
85
|
|
|
75
86
|
return m
|
|
76
|
-
|
mistralai/models/sampletype.py
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from
|
|
4
|
+
from mistralai.types import UnrecognizedStr
|
|
5
|
+
from typing import Literal, Union
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
SampleType =
|
|
8
|
+
SampleType = Union[
|
|
9
|
+
Literal["pretrain", "instruct", "batch_request", "batch_result", "batch_error"],
|
|
10
|
+
UnrecognizedStr,
|
|
11
|
+
]
|
mistralai/models/security.py
CHANGED
|
@@ -3,14 +3,23 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
5
|
from mistralai.utils import FieldMetadata, SecurityMetadata
|
|
6
|
-
from typing import Optional
|
|
7
|
-
from typing_extensions import Annotated, NotRequired
|
|
6
|
+
from typing import Optional
|
|
7
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class SecurityTypedDict(TypedDict):
|
|
11
11
|
api_key: NotRequired[str]
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
|
|
14
14
|
class Security(BaseModel):
|
|
15
|
-
api_key: Annotated[
|
|
16
|
-
|
|
15
|
+
api_key: Annotated[
|
|
16
|
+
Optional[str],
|
|
17
|
+
FieldMetadata(
|
|
18
|
+
security=SecurityMetadata(
|
|
19
|
+
scheme=True,
|
|
20
|
+
scheme_type="http",
|
|
21
|
+
sub_type="bearer",
|
|
22
|
+
field_name="Authorization",
|
|
23
|
+
)
|
|
24
|
+
),
|
|
25
|
+
] = None
|
mistralai/models/source.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from
|
|
4
|
+
from mistralai.types import UnrecognizedStr
|
|
5
|
+
from typing import Literal, Union
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
Source = Literal["upload", "repository"]
|
|
8
|
+
Source = Union[Literal["upload", "repository", "mistral"], UnrecognizedStr]
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from .
|
|
4
|
+
from .textchunk import TextChunk, TextChunkTypedDict
|
|
5
5
|
from mistralai.types import BaseModel
|
|
6
|
-
from typing import List, Literal, Optional,
|
|
7
|
-
from typing_extensions import NotRequired
|
|
6
|
+
from typing import List, Literal, Optional, Union
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
SystemMessageContentTypedDict = Union[str, List[TextChunkTypedDict]]
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
SystemMessageContent = Union[str, List[TextChunk]]
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
Role = Literal["system"]
|
|
17
17
|
|
|
18
|
+
|
|
18
19
|
class SystemMessageTypedDict(TypedDict):
|
|
19
|
-
content:
|
|
20
|
+
content: SystemMessageContentTypedDict
|
|
20
21
|
role: NotRequired[Role]
|
|
21
|
-
|
|
22
|
+
|
|
22
23
|
|
|
23
24
|
class SystemMessage(BaseModel):
|
|
24
|
-
content:
|
|
25
|
+
content: SystemMessageContent
|
|
26
|
+
|
|
25
27
|
role: Optional[Role] = "system"
|
|
26
|
-
|
mistralai/models/textchunk.py
CHANGED
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
|
+
from mistralai.utils import validate_const
|
|
5
6
|
import pydantic
|
|
6
|
-
from
|
|
7
|
-
from
|
|
7
|
+
from pydantic.functional_validators import AfterValidator
|
|
8
|
+
from typing import Literal, Optional
|
|
9
|
+
from typing_extensions import Annotated, TypedDict
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
TextChunkType = Literal["text"]
|
|
8
13
|
|
|
9
14
|
|
|
10
15
|
class TextChunkTypedDict(TypedDict):
|
|
11
16
|
text: str
|
|
12
|
-
|
|
17
|
+
type: TextChunkType
|
|
18
|
+
|
|
13
19
|
|
|
14
20
|
class TextChunk(BaseModel):
|
|
15
21
|
text: str
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
|
|
23
|
+
TYPE: Annotated[
|
|
24
|
+
Annotated[Optional[TextChunkType], AfterValidator(validate_const("text"))],
|
|
25
|
+
pydantic.Field(alias="type"),
|
|
26
|
+
] = "text"
|
mistralai/models/tool.py
CHANGED
|
@@ -2,21 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .function import Function, FunctionTypedDict
|
|
5
|
-
from
|
|
5
|
+
from .tooltypes import ToolTypes
|
|
6
|
+
from mistralai.types import BaseModel
|
|
6
7
|
from mistralai.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
|
-
ToolToolTypes = Union[Literal["function"], UnrecognizedStr]
|
|
13
|
-
|
|
14
13
|
class ToolTypedDict(TypedDict):
|
|
15
14
|
function: FunctionTypedDict
|
|
16
|
-
type: NotRequired[
|
|
17
|
-
|
|
15
|
+
type: NotRequired[ToolTypes]
|
|
16
|
+
|
|
18
17
|
|
|
19
18
|
class Tool(BaseModel):
|
|
20
19
|
function: Function
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
|
|
21
|
+
type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = (
|
|
22
|
+
None
|
|
23
|
+
)
|
mistralai/models/toolcall.py
CHANGED
|
@@ -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.types import BaseModel
|
|
6
7
|
from mistralai.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.types import BaseModel
|
|
7
|
+
from mistralai.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
|
+
)
|
mistralai/models/toolmessage.py
CHANGED
|
@@ -3,25 +3,29 @@
|
|
|
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 Literal, Optional
|
|
7
|
-
from typing_extensions import NotRequired
|
|
6
|
+
from typing import Literal, Optional
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
ToolMessageRole = Literal["tool"]
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
class ToolMessageTypedDict(TypedDict):
|
|
13
14
|
content: str
|
|
14
15
|
tool_call_id: NotRequired[Nullable[str]]
|
|
15
16
|
name: NotRequired[Nullable[str]]
|
|
16
17
|
role: NotRequired[ToolMessageRole]
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
|
|
19
20
|
class ToolMessage(BaseModel):
|
|
20
21
|
content: str
|
|
22
|
+
|
|
21
23
|
tool_call_id: OptionalNullable[str] = UNSET
|
|
24
|
+
|
|
22
25
|
name: OptionalNullable[str] = UNSET
|
|
26
|
+
|
|
23
27
|
role: Optional[ToolMessageRole] = "tool"
|
|
24
|
-
|
|
28
|
+
|
|
25
29
|
@model_serializer(mode="wrap")
|
|
26
30
|
def serialize_model(self, handler):
|
|
27
31
|
optional_fields = ["tool_call_id", "name", "role"]
|
|
@@ -35,9 +39,13 @@ class ToolMessage(BaseModel):
|
|
|
35
39
|
for n, f in self.model_fields.items():
|
|
36
40
|
k = f.alias or n
|
|
37
41
|
val = serialized.get(k)
|
|
42
|
+
serialized.pop(k, None)
|
|
38
43
|
|
|
39
44
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
40
|
-
is_set = (
|
|
45
|
+
is_set = (
|
|
46
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
47
|
+
or k in null_default_fields
|
|
48
|
+
) # pylint: disable=no-member
|
|
41
49
|
|
|
42
50
|
if val is not None and val != UNSET_SENTINEL:
|
|
43
51
|
m[k] = val
|
|
@@ -47,4 +55,3 @@ class ToolMessage(BaseModel):
|
|
|
47
55
|
m[k] = val
|
|
48
56
|
|
|
49
57
|
return m
|
|
50
|
-
|
mistralai/models/trainingfile.py
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
|
-
from typing import Optional
|
|
6
|
-
from typing_extensions import NotRequired
|
|
5
|
+
from typing import Optional
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class TrainingFileTypedDict(TypedDict):
|
|
10
10
|
file_id: str
|
|
11
11
|
weight: NotRequired[float]
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
|
|
14
14
|
class TrainingFile(BaseModel):
|
|
15
15
|
file_id: str
|
|
16
|
+
|
|
16
17
|
weight: Optional[float] = 1
|
|
17
|
-
|
|
@@ -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 Optional
|
|
7
|
-
from typing_extensions import NotRequired
|
|
6
|
+
from typing import Optional
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class TrainingParametersTypedDict(TypedDict):
|
|
@@ -14,20 +14,43 @@ class TrainingParametersTypedDict(TypedDict):
|
|
|
14
14
|
warmup_fraction: NotRequired[Nullable[float]]
|
|
15
15
|
epochs: NotRequired[Nullable[float]]
|
|
16
16
|
fim_ratio: NotRequired[Nullable[float]]
|
|
17
|
-
|
|
17
|
+
seq_len: NotRequired[Nullable[int]]
|
|
18
|
+
|
|
18
19
|
|
|
19
20
|
class TrainingParameters(BaseModel):
|
|
20
21
|
training_steps: OptionalNullable[int] = UNSET
|
|
22
|
+
|
|
21
23
|
learning_rate: Optional[float] = 0.0001
|
|
24
|
+
|
|
22
25
|
weight_decay: OptionalNullable[float] = UNSET
|
|
26
|
+
|
|
23
27
|
warmup_fraction: OptionalNullable[float] = UNSET
|
|
28
|
+
|
|
24
29
|
epochs: OptionalNullable[float] = UNSET
|
|
30
|
+
|
|
25
31
|
fim_ratio: OptionalNullable[float] = UNSET
|
|
26
|
-
|
|
32
|
+
|
|
33
|
+
seq_len: OptionalNullable[int] = UNSET
|
|
34
|
+
|
|
27
35
|
@model_serializer(mode="wrap")
|
|
28
36
|
def serialize_model(self, handler):
|
|
29
|
-
optional_fields = [
|
|
30
|
-
|
|
37
|
+
optional_fields = [
|
|
38
|
+
"training_steps",
|
|
39
|
+
"learning_rate",
|
|
40
|
+
"weight_decay",
|
|
41
|
+
"warmup_fraction",
|
|
42
|
+
"epochs",
|
|
43
|
+
"fim_ratio",
|
|
44
|
+
"seq_len",
|
|
45
|
+
]
|
|
46
|
+
nullable_fields = [
|
|
47
|
+
"training_steps",
|
|
48
|
+
"weight_decay",
|
|
49
|
+
"warmup_fraction",
|
|
50
|
+
"epochs",
|
|
51
|
+
"fim_ratio",
|
|
52
|
+
"seq_len",
|
|
53
|
+
]
|
|
31
54
|
null_default_fields = []
|
|
32
55
|
|
|
33
56
|
serialized = handler(self)
|
|
@@ -37,9 +60,13 @@ class TrainingParameters(BaseModel):
|
|
|
37
60
|
for n, f in self.model_fields.items():
|
|
38
61
|
k = f.alias or n
|
|
39
62
|
val = serialized.get(k)
|
|
63
|
+
serialized.pop(k, None)
|
|
40
64
|
|
|
41
65
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
42
|
-
is_set = (
|
|
66
|
+
is_set = (
|
|
67
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
68
|
+
or k in null_default_fields
|
|
69
|
+
) # pylint: disable=no-member
|
|
43
70
|
|
|
44
71
|
if val is not None and val != UNSET_SENTINEL:
|
|
45
72
|
m[k] = val
|
|
@@ -49,4 +76,3 @@ class TrainingParameters(BaseModel):
|
|
|
49
76
|
m[k] = val
|
|
50
77
|
|
|
51
78
|
return m
|
|
52
|
-
|
|
@@ -3,13 +3,13 @@
|
|
|
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 Optional
|
|
7
|
-
from typing_extensions import NotRequired
|
|
6
|
+
from typing import Optional
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class TrainingParametersInTypedDict(TypedDict):
|
|
11
11
|
r"""The fine-tuning hyperparameter settings used in a fine-tune job."""
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
training_steps: NotRequired[Nullable[int]]
|
|
14
14
|
r"""The number of training steps to perform. A training step refers to a single update of the model weights during the fine-tuning process. This update is typically calculated using a batch of samples from the training dataset."""
|
|
15
15
|
learning_rate: NotRequired[float]
|
|
@@ -20,26 +20,49 @@ class TrainingParametersInTypedDict(TypedDict):
|
|
|
20
20
|
r"""(Advanced Usage) A parameter that specifies the percentage of the total training steps at which the learning rate warm-up phase ends. During this phase, the learning rate gradually increases from a small value to the initial learning rate, helping to stabilize the training process and improve convergence. Similar to `pct_start` in [mistral-finetune](https://github.com/mistralai/mistral-finetune)"""
|
|
21
21
|
epochs: NotRequired[Nullable[float]]
|
|
22
22
|
fim_ratio: NotRequired[Nullable[float]]
|
|
23
|
-
|
|
23
|
+
seq_len: NotRequired[Nullable[int]]
|
|
24
|
+
|
|
24
25
|
|
|
25
26
|
class TrainingParametersIn(BaseModel):
|
|
26
27
|
r"""The fine-tuning hyperparameter settings used in a fine-tune job."""
|
|
27
|
-
|
|
28
|
+
|
|
28
29
|
training_steps: OptionalNullable[int] = UNSET
|
|
29
30
|
r"""The number of training steps to perform. A training step refers to a single update of the model weights during the fine-tuning process. This update is typically calculated using a batch of samples from the training dataset."""
|
|
31
|
+
|
|
30
32
|
learning_rate: Optional[float] = 0.0001
|
|
31
33
|
r"""A parameter describing how much to adjust the pre-trained model's weights in response to the estimated error each time the weights are updated during the fine-tuning process."""
|
|
34
|
+
|
|
32
35
|
weight_decay: OptionalNullable[float] = UNSET
|
|
33
36
|
r"""(Advanced Usage) Weight decay adds a term to the loss function that is proportional to the sum of the squared weights. This term reduces the magnitude of the weights and prevents them from growing too large."""
|
|
37
|
+
|
|
34
38
|
warmup_fraction: OptionalNullable[float] = UNSET
|
|
35
39
|
r"""(Advanced Usage) A parameter that specifies the percentage of the total training steps at which the learning rate warm-up phase ends. During this phase, the learning rate gradually increases from a small value to the initial learning rate, helping to stabilize the training process and improve convergence. Similar to `pct_start` in [mistral-finetune](https://github.com/mistralai/mistral-finetune)"""
|
|
40
|
+
|
|
36
41
|
epochs: OptionalNullable[float] = UNSET
|
|
42
|
+
|
|
37
43
|
fim_ratio: OptionalNullable[float] = UNSET
|
|
38
|
-
|
|
44
|
+
|
|
45
|
+
seq_len: OptionalNullable[int] = UNSET
|
|
46
|
+
|
|
39
47
|
@model_serializer(mode="wrap")
|
|
40
48
|
def serialize_model(self, handler):
|
|
41
|
-
optional_fields = [
|
|
42
|
-
|
|
49
|
+
optional_fields = [
|
|
50
|
+
"training_steps",
|
|
51
|
+
"learning_rate",
|
|
52
|
+
"weight_decay",
|
|
53
|
+
"warmup_fraction",
|
|
54
|
+
"epochs",
|
|
55
|
+
"fim_ratio",
|
|
56
|
+
"seq_len",
|
|
57
|
+
]
|
|
58
|
+
nullable_fields = [
|
|
59
|
+
"training_steps",
|
|
60
|
+
"weight_decay",
|
|
61
|
+
"warmup_fraction",
|
|
62
|
+
"epochs",
|
|
63
|
+
"fim_ratio",
|
|
64
|
+
"seq_len",
|
|
65
|
+
]
|
|
43
66
|
null_default_fields = []
|
|
44
67
|
|
|
45
68
|
serialized = handler(self)
|
|
@@ -49,9 +72,13 @@ class TrainingParametersIn(BaseModel):
|
|
|
49
72
|
for n, f in self.model_fields.items():
|
|
50
73
|
k = f.alias or n
|
|
51
74
|
val = serialized.get(k)
|
|
75
|
+
serialized.pop(k, None)
|
|
52
76
|
|
|
53
77
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
54
|
-
is_set = (
|
|
78
|
+
is_set = (
|
|
79
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
80
|
+
or k in null_default_fields
|
|
81
|
+
) # pylint: disable=no-member
|
|
55
82
|
|
|
56
83
|
if val is not None and val != UNSET_SENTINEL:
|
|
57
84
|
m[k] = val
|
|
@@ -61,4 +88,3 @@ class TrainingParametersIn(BaseModel):
|
|
|
61
88
|
m[k] = val
|
|
62
89
|
|
|
63
90
|
return m
|
|
64
|
-
|
|
@@ -2,20 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
|
+
from mistralai.utils import validate_const
|
|
5
6
|
import pydantic
|
|
6
|
-
from
|
|
7
|
-
from
|
|
7
|
+
from pydantic.functional_validators import AfterValidator
|
|
8
|
+
from typing import Literal, Optional
|
|
9
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
UnarchiveFTModelOutObject = Literal["model"]
|
|
11
13
|
|
|
14
|
+
|
|
12
15
|
class UnarchiveFTModelOutTypedDict(TypedDict):
|
|
13
16
|
id: str
|
|
17
|
+
object: UnarchiveFTModelOutObject
|
|
14
18
|
archived: NotRequired[bool]
|
|
15
|
-
|
|
19
|
+
|
|
16
20
|
|
|
17
21
|
class UnarchiveFTModelOut(BaseModel):
|
|
18
22
|
id: str
|
|
19
|
-
|
|
23
|
+
|
|
24
|
+
OBJECT: Annotated[
|
|
25
|
+
Annotated[
|
|
26
|
+
Optional[UnarchiveFTModelOutObject], AfterValidator(validate_const("model"))
|
|
27
|
+
],
|
|
28
|
+
pydantic.Field(alias="object"),
|
|
29
|
+
] = "model"
|
|
30
|
+
|
|
20
31
|
archived: Optional[bool] = False
|
|
21
|
-
|
|
@@ -3,19 +3,19 @@
|
|
|
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
|
|
7
|
-
from typing_extensions import NotRequired
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class UpdateFTModelInTypedDict(TypedDict):
|
|
11
10
|
name: NotRequired[Nullable[str]]
|
|
12
11
|
description: NotRequired[Nullable[str]]
|
|
13
|
-
|
|
12
|
+
|
|
14
13
|
|
|
15
14
|
class UpdateFTModelIn(BaseModel):
|
|
16
15
|
name: OptionalNullable[str] = UNSET
|
|
16
|
+
|
|
17
17
|
description: OptionalNullable[str] = UNSET
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
@model_serializer(mode="wrap")
|
|
20
20
|
def serialize_model(self, handler):
|
|
21
21
|
optional_fields = ["name", "description"]
|
|
@@ -29,9 +29,13 @@ class UpdateFTModelIn(BaseModel):
|
|
|
29
29
|
for n, f in self.model_fields.items():
|
|
30
30
|
k = f.alias or n
|
|
31
31
|
val = serialized.get(k)
|
|
32
|
+
serialized.pop(k, None)
|
|
32
33
|
|
|
33
34
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
34
|
-
is_set = (
|
|
35
|
+
is_set = (
|
|
36
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
37
|
+
or k in null_default_fields
|
|
38
|
+
) # pylint: disable=no-member
|
|
35
39
|
|
|
36
40
|
if val is not None and val != UNSET_SENTINEL:
|
|
37
41
|
m[k] = val
|
|
@@ -41,4 +45,3 @@ class UpdateFTModelIn(BaseModel):
|
|
|
41
45
|
m[k] = val
|
|
42
46
|
|
|
43
47
|
return m
|
|
44
|
-
|