mistralai 1.0.0rc2__py3-none-any.whl → 1.0.2__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/agents.py +33 -33
- mistralai/chat.py +4 -4
- mistralai/client.py +1 -1
- mistralai/jobs.py +24 -34
- mistralai/models/__init__.py +22 -22
- mistralai/models/agentscompletionrequest.py +14 -14
- mistralai/models/agentscompletionstreamrequest.py +41 -39
- mistralai/models/archiveftmodelout.py +4 -2
- mistralai/models/chatcompletionchoice.py +3 -4
- mistralai/models/chatcompletionrequest.py +16 -16
- mistralai/models/chatcompletionstreamrequest.py +16 -16
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +2 -0
- mistralai/models/deltamessage.py +6 -6
- mistralai/models/detailedjobout.py +19 -5
- mistralai/models/embeddingrequest.py +8 -8
- mistralai/models/files_api_routes_upload_fileop.py +7 -4
- mistralai/models/fileschema.py +8 -3
- mistralai/models/fimcompletionrequest.py +8 -8
- mistralai/models/fimcompletionstreamrequest.py +8 -8
- mistralai/models/ftmodelout.py +4 -2
- mistralai/models/functioncall.py +9 -3
- mistralai/models/githubrepositoryin.py +4 -2
- mistralai/models/githubrepositoryout.py +4 -2
- mistralai/models/jobin.py +16 -4
- mistralai/models/jobout.py +20 -5
- mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +2 -0
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +1 -54
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +2 -0
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +2 -0
- mistralai/models/jobsout.py +4 -2
- mistralai/models/legacyjobmetadataout.py +4 -2
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -0
- mistralai/models/retrievefileout.py +8 -3
- mistralai/models/systemmessage.py +6 -6
- mistralai/models/tool.py +9 -5
- mistralai/models/toolcall.py +8 -4
- mistralai/models/trainingparameters.py +6 -2
- mistralai/models/trainingparametersin.py +10 -2
- mistralai/models/unarchiveftmodelout.py +4 -2
- mistralai/models/uploadfileout.py +8 -3
- mistralai/models/usermessage.py +6 -6
- mistralai/models/validationerror.py +6 -6
- mistralai/models/wandbintegration.py +4 -2
- mistralai/models/wandbintegrationout.py +4 -2
- mistralai/models_.py +10 -10
- mistralai/sdk.py +2 -2
- mistralai/sdkconfiguration.py +3 -3
- mistralai/utils/__init__.py +2 -2
- mistralai/utils/forms.py +10 -9
- mistralai/utils/headers.py +8 -8
- mistralai/utils/logger.py +8 -0
- mistralai/utils/queryparams.py +16 -14
- mistralai/utils/serializers.py +17 -8
- mistralai/utils/url.py +13 -8
- mistralai/utils/values.py +6 -0
- mistralai/version.py +7 -0
- {mistralai-1.0.0rc2.dist-info → mistralai-1.0.2.dist-info}/METADATA +40 -18
- {mistralai-1.0.0rc2.dist-info → mistralai-1.0.2.dist-info}/RECORD +87 -86
- mistralai_azure/models/__init__.py +4 -4
- mistralai_azure/models/chatcompletionchoice.py +3 -4
- mistralai_azure/models/chatcompletionrequest.py +14 -14
- mistralai_azure/models/chatcompletionstreamrequest.py +14 -14
- mistralai_azure/models/deltamessage.py +6 -6
- mistralai_azure/models/functioncall.py +9 -3
- mistralai_azure/models/systemmessage.py +6 -6
- mistralai_azure/models/tool.py +9 -5
- mistralai_azure/models/toolcall.py +8 -4
- mistralai_azure/models/usermessage.py +6 -6
- mistralai_azure/models/validationerror.py +6 -6
- mistralai_azure/sdkconfiguration.py +3 -3
- mistralai_gcp/chat.py +4 -4
- mistralai_gcp/models/__init__.py +4 -4
- mistralai_gcp/models/chatcompletionchoice.py +3 -4
- mistralai_gcp/models/chatcompletionrequest.py +16 -16
- mistralai_gcp/models/chatcompletionstreamrequest.py +16 -16
- mistralai_gcp/models/deltamessage.py +6 -6
- mistralai_gcp/models/fimcompletionrequest.py +8 -8
- mistralai_gcp/models/fimcompletionstreamrequest.py +8 -8
- mistralai_gcp/models/functioncall.py +9 -3
- mistralai_gcp/models/systemmessage.py +6 -6
- mistralai_gcp/models/tool.py +9 -5
- mistralai_gcp/models/toolcall.py +8 -4
- mistralai_gcp/models/usermessage.py +6 -6
- mistralai_gcp/models/validationerror.py +6 -6
- mistralai_gcp/sdkconfiguration.py +3 -3
- {mistralai-1.0.0rc2.dist-info → mistralai-1.0.2.dist-info}/LICENSE +0 -0
- {mistralai-1.0.0rc2.dist-info → mistralai-1.0.2.dist-info}/WHEEL +0 -0
|
@@ -1,64 +1,11 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from .jobin import JobIn, JobInTypedDict
|
|
5
4
|
from .jobout import JobOut, JobOutTypedDict
|
|
6
5
|
from .legacyjobmetadataout import LegacyJobMetadataOut, LegacyJobMetadataOutTypedDict
|
|
7
|
-
from
|
|
8
|
-
from mistralai.utils import FieldMetadata, QueryParamMetadata, RequestMetadata
|
|
9
|
-
from pydantic import model_serializer
|
|
10
|
-
from typing import TypedDict, Union
|
|
11
|
-
from typing_extensions import Annotated, NotRequired
|
|
6
|
+
from typing import Union
|
|
12
7
|
|
|
13
8
|
|
|
14
|
-
class JobsAPIRoutesFineTuningCreateFineTuningJobRequestTypedDict(TypedDict):
|
|
15
|
-
job_in: JobInTypedDict
|
|
16
|
-
dry_run: NotRequired[Nullable[bool]]
|
|
17
|
-
r"""* If `true` the job is not spawned, instead the query returns a handful of useful metadata
|
|
18
|
-
for the user to perform sanity checks (see `LegacyJobMetadataOut` response).
|
|
19
|
-
* Otherwise, the job is started and the query returns the job ID along with some of the
|
|
20
|
-
input parameters (see `JobOut` response).
|
|
21
|
-
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class JobsAPIRoutesFineTuningCreateFineTuningJobRequest(BaseModel):
|
|
26
|
-
job_in: Annotated[JobIn, FieldMetadata(request=RequestMetadata(media_type="application/json"))]
|
|
27
|
-
dry_run: Annotated[OptionalNullable[bool], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = UNSET
|
|
28
|
-
r"""* If `true` the job is not spawned, instead the query returns a handful of useful metadata
|
|
29
|
-
for the user to perform sanity checks (see `LegacyJobMetadataOut` response).
|
|
30
|
-
* Otherwise, the job is started and the query returns the job ID along with some of the
|
|
31
|
-
input parameters (see `JobOut` response).
|
|
32
|
-
|
|
33
|
-
"""
|
|
34
|
-
|
|
35
|
-
@model_serializer(mode="wrap")
|
|
36
|
-
def serialize_model(self, handler):
|
|
37
|
-
optional_fields = ["dry_run"]
|
|
38
|
-
nullable_fields = ["dry_run"]
|
|
39
|
-
null_default_fields = []
|
|
40
|
-
|
|
41
|
-
serialized = handler(self)
|
|
42
|
-
|
|
43
|
-
m = {}
|
|
44
|
-
|
|
45
|
-
for n, f in self.model_fields.items():
|
|
46
|
-
k = f.alias or n
|
|
47
|
-
val = serialized.get(k)
|
|
48
|
-
|
|
49
|
-
optional_nullable = k in optional_fields and k in nullable_fields
|
|
50
|
-
is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
|
|
51
|
-
|
|
52
|
-
if val is not None and val != UNSET_SENTINEL:
|
|
53
|
-
m[k] = val
|
|
54
|
-
elif val != UNSET_SENTINEL and (
|
|
55
|
-
not k in optional_fields or (optional_nullable and is_set)
|
|
56
|
-
):
|
|
57
|
-
m[k] = val
|
|
58
|
-
|
|
59
|
-
return m
|
|
60
|
-
|
|
61
|
-
|
|
62
9
|
JobsAPIRoutesFineTuningCreateFineTuningJobResponseTypedDict = Union[LegacyJobMetadataOutTypedDict, JobOutTypedDict]
|
|
63
10
|
r"""OK"""
|
|
64
11
|
|
|
@@ -9,8 +9,10 @@ from typing_extensions import Annotated
|
|
|
9
9
|
|
|
10
10
|
class JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequestTypedDict(TypedDict):
|
|
11
11
|
model_id: str
|
|
12
|
+
r"""The ID of the model to unarchive."""
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequest(BaseModel):
|
|
15
16
|
model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
|
|
17
|
+
r"""The ID of the model to unarchive."""
|
|
16
18
|
|
|
@@ -10,10 +10,12 @@ from typing_extensions import Annotated
|
|
|
10
10
|
|
|
11
11
|
class JobsAPIRoutesFineTuningUpdateFineTunedModelRequestTypedDict(TypedDict):
|
|
12
12
|
model_id: str
|
|
13
|
+
r"""The ID of the model to update."""
|
|
13
14
|
update_ft_model_in: UpdateFTModelInTypedDict
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class JobsAPIRoutesFineTuningUpdateFineTunedModelRequest(BaseModel):
|
|
17
18
|
model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
|
|
19
|
+
r"""The ID of the model to update."""
|
|
18
20
|
update_ft_model_in: Annotated[UpdateFTModelIn, FieldMetadata(request=RequestMetadata(media_type="application/json"))]
|
|
19
21
|
|
mistralai/models/jobsout.py
CHANGED
|
@@ -4,10 +4,12 @@ from __future__ import annotations
|
|
|
4
4
|
from .jobout import JobOut, JobOutTypedDict
|
|
5
5
|
from mistralai.types import BaseModel
|
|
6
6
|
import pydantic
|
|
7
|
-
from typing import Final, List, Optional, TypedDict
|
|
7
|
+
from typing import Final, List, Literal, Optional, TypedDict
|
|
8
8
|
from typing_extensions import Annotated, NotRequired
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
JobsOutObject = Literal["list"]
|
|
12
|
+
|
|
11
13
|
class JobsOutTypedDict(TypedDict):
|
|
12
14
|
total: int
|
|
13
15
|
data: NotRequired[List[JobOutTypedDict]]
|
|
@@ -16,5 +18,5 @@ class JobsOutTypedDict(TypedDict):
|
|
|
16
18
|
class JobsOut(BaseModel):
|
|
17
19
|
total: int
|
|
18
20
|
data: Optional[List[JobOut]] = None
|
|
19
|
-
OBJECT: Annotated[Final[Optional[
|
|
21
|
+
OBJECT: Annotated[Final[Optional[JobsOutObject]], pydantic.Field(alias="object")] = "list" # type: ignore
|
|
20
22
|
|
|
@@ -4,10 +4,12 @@ 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 Final, Optional, TypedDict
|
|
7
|
+
from typing import Final, Literal, Optional, TypedDict
|
|
8
8
|
from typing_extensions import Annotated, NotRequired
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
LegacyJobMetadataOutObject = Literal["job.metadata"]
|
|
12
|
+
|
|
11
13
|
class LegacyJobMetadataOutTypedDict(TypedDict):
|
|
12
14
|
details: str
|
|
13
15
|
expected_duration_seconds: NotRequired[Nullable[int]]
|
|
@@ -50,7 +52,7 @@ class LegacyJobMetadataOut(BaseModel):
|
|
|
50
52
|
r"""The number of complete passes through the entire training dataset."""
|
|
51
53
|
training_steps: OptionalNullable[int] = UNSET
|
|
52
54
|
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."""
|
|
53
|
-
OBJECT: Annotated[Final[Optional[
|
|
55
|
+
OBJECT: Annotated[Final[Optional[LegacyJobMetadataOutObject]], pydantic.Field(alias="object")] = "job.metadata" # type: ignore
|
|
54
56
|
|
|
55
57
|
@model_serializer(mode="wrap")
|
|
56
58
|
def serialize_model(self, handler):
|
|
@@ -9,8 +9,10 @@ from typing_extensions import Annotated
|
|
|
9
9
|
|
|
10
10
|
class RetrieveModelV1ModelsModelIDGetRequestTypedDict(TypedDict):
|
|
11
11
|
model_id: str
|
|
12
|
+
r"""The ID of the model to retrieve."""
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class RetrieveModelV1ModelsModelIDGetRequest(BaseModel):
|
|
15
16
|
model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
|
|
17
|
+
r"""The ID of the model to retrieve."""
|
|
16
18
|
|
|
@@ -3,13 +3,18 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .sampletype import SampleType
|
|
5
5
|
from .source import Source
|
|
6
|
-
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
6
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL, UnrecognizedStr
|
|
7
|
+
from mistralai.utils import validate_open_enum
|
|
7
8
|
import pydantic
|
|
8
9
|
from pydantic import model_serializer
|
|
9
|
-
from
|
|
10
|
+
from pydantic.functional_validators import PlainValidator
|
|
11
|
+
from typing import Final, Literal, TypedDict, Union
|
|
10
12
|
from typing_extensions import Annotated, NotRequired
|
|
11
13
|
|
|
12
14
|
|
|
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
|
+
|
|
13
18
|
class RetrieveFileOutTypedDict(TypedDict):
|
|
14
19
|
id: str
|
|
15
20
|
r"""The unique identifier of the file."""
|
|
@@ -39,7 +44,7 @@ class RetrieveFileOut(BaseModel):
|
|
|
39
44
|
r"""The name of the uploaded file."""
|
|
40
45
|
sample_type: SampleType
|
|
41
46
|
source: Source
|
|
42
|
-
PURPOSE: Annotated[Final[
|
|
47
|
+
PURPOSE: Annotated[Final[Annotated[RetrieveFileOutPurpose, PlainValidator(validate_open_enum(False))]], pydantic.Field(alias="purpose")] = "fine-tune" # type: ignore
|
|
43
48
|
r"""The intended purpose of the uploaded file. Only accepts fine-tuning (`fine-tune`) for now."""
|
|
44
49
|
num_lines: OptionalNullable[int] = UNSET
|
|
45
50
|
|
|
@@ -7,6 +7,12 @@ from typing import List, Literal, Optional, TypedDict, Union
|
|
|
7
7
|
from typing_extensions import NotRequired
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
ContentTypedDict = Union[str, List[ContentChunkTypedDict]]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Content = Union[str, List[ContentChunk]]
|
|
14
|
+
|
|
15
|
+
|
|
10
16
|
Role = Literal["system"]
|
|
11
17
|
|
|
12
18
|
class SystemMessageTypedDict(TypedDict):
|
|
@@ -18,9 +24,3 @@ class SystemMessage(BaseModel):
|
|
|
18
24
|
content: Content
|
|
19
25
|
role: Optional[Role] = "system"
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
ContentTypedDict = Union[str, List[ContentChunkTypedDict]]
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Content = Union[str, List[ContentChunk]]
|
|
26
|
-
|
mistralai/models/tool.py
CHANGED
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .function import Function, FunctionTypedDict
|
|
5
|
-
from mistralai.types import BaseModel
|
|
6
|
-
import
|
|
7
|
-
from
|
|
8
|
-
from
|
|
5
|
+
from mistralai.types import BaseModel, UnrecognizedStr
|
|
6
|
+
from mistralai.utils import validate_open_enum
|
|
7
|
+
from pydantic.functional_validators import PlainValidator
|
|
8
|
+
from typing import Literal, Optional, TypedDict, Union
|
|
9
|
+
from typing_extensions import Annotated, NotRequired
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
ToolToolTypes = Union[Literal["function"], UnrecognizedStr]
|
|
13
|
+
|
|
11
14
|
class ToolTypedDict(TypedDict):
|
|
12
15
|
function: FunctionTypedDict
|
|
16
|
+
type: NotRequired[ToolToolTypes]
|
|
13
17
|
|
|
14
18
|
|
|
15
19
|
class Tool(BaseModel):
|
|
16
20
|
function: Function
|
|
17
|
-
|
|
21
|
+
type: Annotated[Optional[ToolToolTypes], PlainValidator(validate_open_enum(False))] = "function"
|
|
18
22
|
|
mistralai/models/toolcall.py
CHANGED
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .functioncall import FunctionCall, FunctionCallTypedDict
|
|
5
|
-
from mistralai.types import BaseModel
|
|
6
|
-
import
|
|
7
|
-
from
|
|
5
|
+
from mistralai.types import BaseModel, UnrecognizedStr
|
|
6
|
+
from mistralai.utils import validate_open_enum
|
|
7
|
+
from pydantic.functional_validators import PlainValidator
|
|
8
|
+
from typing import Literal, Optional, TypedDict, Union
|
|
8
9
|
from typing_extensions import Annotated, NotRequired
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
ToolTypes = Union[Literal["function"], UnrecognizedStr]
|
|
13
|
+
|
|
11
14
|
class ToolCallTypedDict(TypedDict):
|
|
12
15
|
function: FunctionCallTypedDict
|
|
13
16
|
id: NotRequired[str]
|
|
17
|
+
type: NotRequired[ToolTypes]
|
|
14
18
|
|
|
15
19
|
|
|
16
20
|
class ToolCall(BaseModel):
|
|
17
21
|
function: FunctionCall
|
|
18
22
|
id: Optional[str] = "null"
|
|
19
|
-
|
|
23
|
+
type: Annotated[Optional[ToolTypes], PlainValidator(validate_open_enum(False))] = "function"
|
|
20
24
|
|
|
@@ -10,6 +10,8 @@ from typing_extensions import NotRequired
|
|
|
10
10
|
class TrainingParametersTypedDict(TypedDict):
|
|
11
11
|
training_steps: NotRequired[Nullable[int]]
|
|
12
12
|
learning_rate: NotRequired[float]
|
|
13
|
+
weight_decay: NotRequired[Nullable[float]]
|
|
14
|
+
warmup_fraction: NotRequired[Nullable[float]]
|
|
13
15
|
epochs: NotRequired[Nullable[float]]
|
|
14
16
|
fim_ratio: NotRequired[Nullable[float]]
|
|
15
17
|
|
|
@@ -17,13 +19,15 @@ class TrainingParametersTypedDict(TypedDict):
|
|
|
17
19
|
class TrainingParameters(BaseModel):
|
|
18
20
|
training_steps: OptionalNullable[int] = UNSET
|
|
19
21
|
learning_rate: Optional[float] = 0.0001
|
|
22
|
+
weight_decay: OptionalNullable[float] = UNSET
|
|
23
|
+
warmup_fraction: OptionalNullable[float] = UNSET
|
|
20
24
|
epochs: OptionalNullable[float] = UNSET
|
|
21
25
|
fim_ratio: OptionalNullable[float] = UNSET
|
|
22
26
|
|
|
23
27
|
@model_serializer(mode="wrap")
|
|
24
28
|
def serialize_model(self, handler):
|
|
25
|
-
optional_fields = ["training_steps", "learning_rate", "epochs", "fim_ratio"]
|
|
26
|
-
nullable_fields = ["training_steps", "epochs", "fim_ratio"]
|
|
29
|
+
optional_fields = ["training_steps", "learning_rate", "weight_decay", "warmup_fraction", "epochs", "fim_ratio"]
|
|
30
|
+
nullable_fields = ["training_steps", "weight_decay", "warmup_fraction", "epochs", "fim_ratio"]
|
|
27
31
|
null_default_fields = []
|
|
28
32
|
|
|
29
33
|
serialized = handler(self)
|
|
@@ -14,6 +14,10 @@ class TrainingParametersInTypedDict(TypedDict):
|
|
|
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]
|
|
16
16
|
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."""
|
|
17
|
+
weight_decay: NotRequired[Nullable[float]]
|
|
18
|
+
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."""
|
|
19
|
+
warmup_fraction: NotRequired[Nullable[float]]
|
|
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)"""
|
|
17
21
|
epochs: NotRequired[Nullable[float]]
|
|
18
22
|
fim_ratio: NotRequired[Nullable[float]]
|
|
19
23
|
|
|
@@ -25,13 +29,17 @@ class TrainingParametersIn(BaseModel):
|
|
|
25
29
|
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."""
|
|
26
30
|
learning_rate: Optional[float] = 0.0001
|
|
27
31
|
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."""
|
|
32
|
+
weight_decay: OptionalNullable[float] = UNSET
|
|
33
|
+
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."""
|
|
34
|
+
warmup_fraction: OptionalNullable[float] = UNSET
|
|
35
|
+
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)"""
|
|
28
36
|
epochs: OptionalNullable[float] = UNSET
|
|
29
37
|
fim_ratio: OptionalNullable[float] = UNSET
|
|
30
38
|
|
|
31
39
|
@model_serializer(mode="wrap")
|
|
32
40
|
def serialize_model(self, handler):
|
|
33
|
-
optional_fields = ["training_steps", "learning_rate", "epochs", "fim_ratio"]
|
|
34
|
-
nullable_fields = ["training_steps", "epochs", "fim_ratio"]
|
|
41
|
+
optional_fields = ["training_steps", "learning_rate", "weight_decay", "warmup_fraction", "epochs", "fim_ratio"]
|
|
42
|
+
nullable_fields = ["training_steps", "weight_decay", "warmup_fraction", "epochs", "fim_ratio"]
|
|
35
43
|
null_default_fields = []
|
|
36
44
|
|
|
37
45
|
serialized = handler(self)
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
5
|
import pydantic
|
|
6
|
-
from typing import Final, Optional, TypedDict
|
|
6
|
+
from typing import Final, Literal, Optional, TypedDict
|
|
7
7
|
from typing_extensions import Annotated, NotRequired
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
UnarchiveFTModelOutObject = Literal["model"]
|
|
11
|
+
|
|
10
12
|
class UnarchiveFTModelOutTypedDict(TypedDict):
|
|
11
13
|
id: str
|
|
12
14
|
archived: NotRequired[bool]
|
|
@@ -14,6 +16,6 @@ class UnarchiveFTModelOutTypedDict(TypedDict):
|
|
|
14
16
|
|
|
15
17
|
class UnarchiveFTModelOut(BaseModel):
|
|
16
18
|
id: str
|
|
17
|
-
OBJECT: Annotated[Final[Optional[
|
|
19
|
+
OBJECT: Annotated[Final[Optional[UnarchiveFTModelOutObject]], pydantic.Field(alias="object")] = "model" # type: ignore
|
|
18
20
|
archived: Optional[bool] = False
|
|
19
21
|
|
|
@@ -3,13 +3,18 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .sampletype import SampleType
|
|
5
5
|
from .source import Source
|
|
6
|
-
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
6
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL, UnrecognizedStr
|
|
7
|
+
from mistralai.utils import validate_open_enum
|
|
7
8
|
import pydantic
|
|
8
9
|
from pydantic import model_serializer
|
|
9
|
-
from
|
|
10
|
+
from pydantic.functional_validators import PlainValidator
|
|
11
|
+
from typing import Final, Literal, TypedDict, Union
|
|
10
12
|
from typing_extensions import Annotated, NotRequired
|
|
11
13
|
|
|
12
14
|
|
|
15
|
+
Purpose = Union[Literal["fine-tune"], UnrecognizedStr]
|
|
16
|
+
r"""The intended purpose of the uploaded file. Only accepts fine-tuning (`fine-tune`) for now."""
|
|
17
|
+
|
|
13
18
|
class UploadFileOutTypedDict(TypedDict):
|
|
14
19
|
id: str
|
|
15
20
|
r"""The unique identifier of the file."""
|
|
@@ -39,7 +44,7 @@ class UploadFileOut(BaseModel):
|
|
|
39
44
|
r"""The name of the uploaded file."""
|
|
40
45
|
sample_type: SampleType
|
|
41
46
|
source: Source
|
|
42
|
-
PURPOSE: Annotated[Final[
|
|
47
|
+
PURPOSE: Annotated[Final[Annotated[Purpose, PlainValidator(validate_open_enum(False))]], pydantic.Field(alias="purpose")] = "fine-tune" # type: ignore
|
|
43
48
|
r"""The intended purpose of the uploaded file. Only accepts fine-tuning (`fine-tune`) for now."""
|
|
44
49
|
num_lines: OptionalNullable[int] = UNSET
|
|
45
50
|
|
mistralai/models/usermessage.py
CHANGED
|
@@ -7,6 +7,12 @@ from typing import List, Literal, Optional, TypedDict, Union
|
|
|
7
7
|
from typing_extensions import NotRequired
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
UserMessageContentTypedDict = Union[str, List[TextChunkTypedDict]]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
UserMessageContent = Union[str, List[TextChunk]]
|
|
14
|
+
|
|
15
|
+
|
|
10
16
|
UserMessageRole = Literal["user"]
|
|
11
17
|
|
|
12
18
|
class UserMessageTypedDict(TypedDict):
|
|
@@ -18,9 +24,3 @@ class UserMessage(BaseModel):
|
|
|
18
24
|
content: UserMessageContent
|
|
19
25
|
role: Optional[UserMessageRole] = "user"
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
UserMessageContentTypedDict = Union[str, List[TextChunkTypedDict]]
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
UserMessageContent = Union[str, List[TextChunk]]
|
|
26
|
-
|
|
@@ -5,6 +5,12 @@ from mistralai.types import BaseModel
|
|
|
5
5
|
from typing import List, TypedDict, Union
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
LocTypedDict = Union[str, int]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Loc = Union[str, int]
|
|
12
|
+
|
|
13
|
+
|
|
8
14
|
class ValidationErrorTypedDict(TypedDict):
|
|
9
15
|
loc: List[LocTypedDict]
|
|
10
16
|
msg: str
|
|
@@ -16,9 +22,3 @@ class ValidationError(BaseModel):
|
|
|
16
22
|
msg: str
|
|
17
23
|
type: str
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
LocTypedDict = Union[str, int]
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Loc = Union[str, int]
|
|
24
|
-
|
|
@@ -4,10 +4,12 @@ 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 Final, Optional, TypedDict
|
|
7
|
+
from typing import Final, Literal, Optional, TypedDict
|
|
8
8
|
from typing_extensions import Annotated, NotRequired
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
WandbIntegrationType = Literal["wandb"]
|
|
12
|
+
|
|
11
13
|
class WandbIntegrationTypedDict(TypedDict):
|
|
12
14
|
project: str
|
|
13
15
|
r"""The name of the project that the new run will be created under."""
|
|
@@ -23,7 +25,7 @@ class WandbIntegration(BaseModel):
|
|
|
23
25
|
r"""The name of the project that the new run will be created under."""
|
|
24
26
|
api_key: str
|
|
25
27
|
r"""The WandB API key to use for authentication."""
|
|
26
|
-
TYPE: Annotated[Final[Optional[
|
|
28
|
+
TYPE: Annotated[Final[Optional[WandbIntegrationType]], pydantic.Field(alias="type")] = "wandb" # type: ignore
|
|
27
29
|
name: OptionalNullable[str] = UNSET
|
|
28
30
|
r"""A display name to set for the run. If not set, will use the job ID as the name."""
|
|
29
31
|
run_name: OptionalNullable[str] = UNSET
|
|
@@ -4,10 +4,12 @@ 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 Final, Optional, TypedDict
|
|
7
|
+
from typing import Final, Literal, Optional, TypedDict
|
|
8
8
|
from typing_extensions import Annotated, NotRequired
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
Type = Literal["wandb"]
|
|
12
|
+
|
|
11
13
|
class WandbIntegrationOutTypedDict(TypedDict):
|
|
12
14
|
project: str
|
|
13
15
|
r"""The name of the project that the new run will be created under."""
|
|
@@ -19,7 +21,7 @@ class WandbIntegrationOutTypedDict(TypedDict):
|
|
|
19
21
|
class WandbIntegrationOut(BaseModel):
|
|
20
22
|
project: str
|
|
21
23
|
r"""The name of the project that the new run will be created under."""
|
|
22
|
-
TYPE: Annotated[Final[Optional[
|
|
24
|
+
TYPE: Annotated[Final[Optional[Type]], pydantic.Field(alias="type")] = "wandb" # type: ignore
|
|
23
25
|
name: OptionalNullable[str] = UNSET
|
|
24
26
|
r"""A display name to set for the run. If not set, will use the job ID as the name."""
|
|
25
27
|
run_name: OptionalNullable[str] = UNSET
|
mistralai/models_.py
CHANGED
|
@@ -164,7 +164,7 @@ class Models(BaseSDK):
|
|
|
164
164
|
|
|
165
165
|
Retrieve a model information.
|
|
166
166
|
|
|
167
|
-
:param model_id:
|
|
167
|
+
:param model_id: The ID of the model to retrieve.
|
|
168
168
|
:param retries: Override the default retry configuration for this method
|
|
169
169
|
:param server_url: Override the default server URL for this method
|
|
170
170
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -242,7 +242,7 @@ class Models(BaseSDK):
|
|
|
242
242
|
|
|
243
243
|
Retrieve a model information.
|
|
244
244
|
|
|
245
|
-
:param model_id:
|
|
245
|
+
:param model_id: The ID of the model to retrieve.
|
|
246
246
|
:param retries: Override the default retry configuration for this method
|
|
247
247
|
:param server_url: Override the default server URL for this method
|
|
248
248
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -320,7 +320,7 @@ class Models(BaseSDK):
|
|
|
320
320
|
|
|
321
321
|
Delete a fine-tuned model.
|
|
322
322
|
|
|
323
|
-
:param model_id:
|
|
323
|
+
:param model_id: The ID of the model to delete.
|
|
324
324
|
:param retries: Override the default retry configuration for this method
|
|
325
325
|
:param server_url: Override the default server URL for this method
|
|
326
326
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -398,7 +398,7 @@ class Models(BaseSDK):
|
|
|
398
398
|
|
|
399
399
|
Delete a fine-tuned model.
|
|
400
400
|
|
|
401
|
-
:param model_id:
|
|
401
|
+
:param model_id: The ID of the model to delete.
|
|
402
402
|
:param retries: Override the default retry configuration for this method
|
|
403
403
|
:param server_url: Override the default server URL for this method
|
|
404
404
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -478,7 +478,7 @@ class Models(BaseSDK):
|
|
|
478
478
|
|
|
479
479
|
Update a model name or description.
|
|
480
480
|
|
|
481
|
-
:param model_id:
|
|
481
|
+
:param model_id: The ID of the model to update.
|
|
482
482
|
:param name:
|
|
483
483
|
:param description:
|
|
484
484
|
:param retries: Override the default retry configuration for this method
|
|
@@ -561,7 +561,7 @@ class Models(BaseSDK):
|
|
|
561
561
|
|
|
562
562
|
Update a model name or description.
|
|
563
563
|
|
|
564
|
-
:param model_id:
|
|
564
|
+
:param model_id: The ID of the model to update.
|
|
565
565
|
:param name:
|
|
566
566
|
:param description:
|
|
567
567
|
:param retries: Override the default retry configuration for this method
|
|
@@ -642,7 +642,7 @@ class Models(BaseSDK):
|
|
|
642
642
|
|
|
643
643
|
Archive a fine-tuned model.
|
|
644
644
|
|
|
645
|
-
:param model_id:
|
|
645
|
+
:param model_id: The ID of the model to archive.
|
|
646
646
|
:param retries: Override the default retry configuration for this method
|
|
647
647
|
:param server_url: Override the default server URL for this method
|
|
648
648
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -716,7 +716,7 @@ class Models(BaseSDK):
|
|
|
716
716
|
|
|
717
717
|
Archive a fine-tuned model.
|
|
718
718
|
|
|
719
|
-
:param model_id:
|
|
719
|
+
:param model_id: The ID of the model to archive.
|
|
720
720
|
:param retries: Override the default retry configuration for this method
|
|
721
721
|
:param server_url: Override the default server URL for this method
|
|
722
722
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -790,7 +790,7 @@ class Models(BaseSDK):
|
|
|
790
790
|
|
|
791
791
|
Un-archive a fine-tuned model.
|
|
792
792
|
|
|
793
|
-
:param model_id:
|
|
793
|
+
:param model_id: The ID of the model to unarchive.
|
|
794
794
|
:param retries: Override the default retry configuration for this method
|
|
795
795
|
:param server_url: Override the default server URL for this method
|
|
796
796
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -864,7 +864,7 @@ class Models(BaseSDK):
|
|
|
864
864
|
|
|
865
865
|
Un-archive a fine-tuned model.
|
|
866
866
|
|
|
867
|
-
:param model_id:
|
|
867
|
+
:param model_id: The ID of the model to unarchive.
|
|
868
868
|
:param retries: Override the default retry configuration for this method
|
|
869
869
|
:param server_url: Override the default server URL for this method
|
|
870
870
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
mistralai/sdk.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from .basesdk import BaseSDK
|
|
4
4
|
from .httpclient import AsyncHttpClient, HttpClient
|
|
5
5
|
from .sdkconfiguration import SDKConfiguration
|
|
6
|
-
from .utils.logger import Logger,
|
|
6
|
+
from .utils.logger import Logger, get_default_logger
|
|
7
7
|
from .utils.retries import RetryConfig
|
|
8
8
|
import httpx
|
|
9
9
|
from mistralai import models, utils
|
|
@@ -67,7 +67,7 @@ class Mistral(BaseSDK):
|
|
|
67
67
|
async_client = httpx.AsyncClient()
|
|
68
68
|
|
|
69
69
|
if debug_logger is None:
|
|
70
|
-
debug_logger =
|
|
70
|
+
debug_logger = get_default_logger()
|
|
71
71
|
|
|
72
72
|
assert issubclass(
|
|
73
73
|
type(async_client), AsyncHttpClient
|
mistralai/sdkconfiguration.py
CHANGED
|
@@ -29,9 +29,9 @@ class SDKConfiguration:
|
|
|
29
29
|
server: Optional[str] = ""
|
|
30
30
|
language: str = "python"
|
|
31
31
|
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.
|
|
32
|
+
sdk_version: str = "1.0.2"
|
|
33
|
+
gen_version: str = "2.402.5"
|
|
34
|
+
user_agent: str = "speakeasy-sdk/python 1.0.2 2.402.5 0.0.2 mistralai"
|
|
35
35
|
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
|
36
36
|
timeout_ms: Optional[int] = None
|
|
37
37
|
|
mistralai/utils/__init__.py
CHANGED
|
@@ -35,7 +35,7 @@ from .serializers import (
|
|
|
35
35
|
)
|
|
36
36
|
from .url import generate_url, template_url, remove_suffix
|
|
37
37
|
from .values import get_global_from_env, match_content_type, match_status_codes, match_response
|
|
38
|
-
from .logger import Logger, get_body_content,
|
|
38
|
+
from .logger import Logger, get_body_content, get_default_logger
|
|
39
39
|
|
|
40
40
|
__all__ = [
|
|
41
41
|
"BackoffStrategy",
|
|
@@ -44,6 +44,7 @@ __all__ = [
|
|
|
44
44
|
"FormMetadata",
|
|
45
45
|
"generate_url",
|
|
46
46
|
"get_body_content",
|
|
47
|
+
"get_default_logger",
|
|
47
48
|
"get_discriminator",
|
|
48
49
|
"get_global_from_env",
|
|
49
50
|
"get_headers",
|
|
@@ -59,7 +60,6 @@ __all__ = [
|
|
|
59
60
|
"match_status_codes",
|
|
60
61
|
"match_response",
|
|
61
62
|
"MultipartFormMetadata",
|
|
62
|
-
"NoOpLogger",
|
|
63
63
|
"OpenEnumMeta",
|
|
64
64
|
"PathParamMetadata",
|
|
65
65
|
"QueryParamMetadata",
|