mistralai 1.0.1__py3-none-any.whl → 1.0.3__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 +31 -31
- mistralai/chat.py +4 -4
- mistralai/jobs.py +8 -8
- mistralai/models/__init__.py +20 -20
- mistralai/models/agentscompletionstreamrequest.py +33 -31
- mistralai/models/archiveftmodelout.py +4 -2
- mistralai/models/chatcompletionchoice.py +3 -4
- mistralai/models/chatcompletionrequest.py +2 -2
- mistralai/models/chatcompletionstreamrequest.py +2 -2
- mistralai/models/deltamessage.py +3 -3
- mistralai/models/detailedjobout.py +19 -5
- mistralai/models/files_api_routes_upload_fileop.py +7 -4
- mistralai/models/fileschema.py +8 -3
- mistralai/models/ftmodelout.py +4 -2
- 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/jobsout.py +4 -2
- mistralai/models/legacyjobmetadataout.py +4 -2
- mistralai/models/retrievefileout.py +8 -3
- 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/wandbintegration.py +4 -2
- mistralai/models/wandbintegrationout.py +4 -2
- 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.1.dist-info → mistralai-1.0.3.dist-info}/METADATA +6 -3
- {mistralai-1.0.1.dist-info → mistralai-1.0.3.dist-info}/RECORD +60 -59
- mistralai_azure/models/__init__.py +3 -3
- mistralai_azure/models/chatcompletionchoice.py +3 -4
- mistralai_azure/models/deltamessage.py +3 -3
- mistralai_azure/models/tool.py +9 -5
- mistralai_azure/models/toolcall.py +8 -4
- mistralai_azure/sdkconfiguration.py +3 -3
- mistralai_gcp/chat.py +4 -4
- mistralai_gcp/models/__init__.py +3 -3
- mistralai_gcp/models/chatcompletionchoice.py +3 -4
- mistralai_gcp/models/chatcompletionrequest.py +2 -2
- mistralai_gcp/models/chatcompletionstreamrequest.py +2 -2
- mistralai_gcp/models/deltamessage.py +3 -3
- mistralai_gcp/models/tool.py +9 -5
- mistralai_gcp/models/toolcall.py +8 -4
- mistralai_gcp/sdk.py +17 -12
- mistralai_gcp/sdkconfiguration.py +3 -3
- {mistralai-1.0.1.dist-info → mistralai-1.0.3.dist-info}/LICENSE +0 -0
- {mistralai-1.0.1.dist-info → mistralai-1.0.3.dist-info}/WHEEL +0 -0
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
import io
|
|
5
|
-
from mistralai.types import BaseModel
|
|
6
|
-
from mistralai.utils import FieldMetadata, MultipartFormMetadata
|
|
5
|
+
from mistralai.types import BaseModel, UnrecognizedStr
|
|
6
|
+
from mistralai.utils import FieldMetadata, MultipartFormMetadata, validate_open_enum
|
|
7
7
|
import pydantic
|
|
8
|
-
from
|
|
8
|
+
from pydantic.functional_validators import PlainValidator
|
|
9
|
+
from typing import Final, IO, Literal, Optional, TypedDict, Union
|
|
9
10
|
from typing_extensions import Annotated, NotRequired
|
|
10
11
|
|
|
11
12
|
|
|
13
|
+
FilesAPIRoutesUploadFilePurpose = Union[Literal["fine-tune"], UnrecognizedStr]
|
|
14
|
+
|
|
12
15
|
class FileTypedDict(TypedDict):
|
|
13
16
|
file_name: str
|
|
14
17
|
content: Union[bytes, IO[bytes], io.BufferedReader]
|
|
@@ -47,5 +50,5 @@ class FilesAPIRoutesUploadFileMultiPartBodyParams(BaseModel):
|
|
|
47
50
|
file=@path/to/your/file.jsonl
|
|
48
51
|
```
|
|
49
52
|
"""
|
|
50
|
-
PURPOSE: Annotated[Final[Optional[
|
|
53
|
+
PURPOSE: Annotated[Final[Annotated[Optional[FilesAPIRoutesUploadFilePurpose], PlainValidator(validate_open_enum(False))]], pydantic.Field(alias="purpose"), FieldMetadata(multipart=True)] = "fine-tune" # type: ignore
|
|
51
54
|
|
mistralai/models/fileschema.py
CHANGED
|
@@ -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
|
+
FileSchemaPurpose = 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 FileSchemaTypedDict(TypedDict):
|
|
14
19
|
id: str
|
|
15
20
|
r"""The unique identifier of the file."""
|
|
@@ -39,7 +44,7 @@ class FileSchema(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[FileSchemaPurpose, 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/ftmodelout.py
CHANGED
|
@@ -5,10 +5,12 @@ from .ftmodelcapabilitiesout import FTModelCapabilitiesOut, FTModelCapabilitiesO
|
|
|
5
5
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
6
6
|
import pydantic
|
|
7
7
|
from pydantic import model_serializer
|
|
8
|
-
from typing import Final, List, Optional, TypedDict
|
|
8
|
+
from typing import Final, List, Literal, Optional, TypedDict
|
|
9
9
|
from typing_extensions import Annotated, NotRequired
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
FTModelOutObject = Literal["model"]
|
|
13
|
+
|
|
12
14
|
class FTModelOutTypedDict(TypedDict):
|
|
13
15
|
id: str
|
|
14
16
|
created: int
|
|
@@ -31,7 +33,7 @@ class FTModelOut(BaseModel):
|
|
|
31
33
|
archived: bool
|
|
32
34
|
capabilities: FTModelCapabilitiesOut
|
|
33
35
|
job: str
|
|
34
|
-
OBJECT: Annotated[Final[Optional[
|
|
36
|
+
OBJECT: Annotated[Final[Optional[FTModelOutObject]], pydantic.Field(alias="object")] = "model" # type: ignore
|
|
35
37
|
name: OptionalNullable[str] = UNSET
|
|
36
38
|
description: OptionalNullable[str] = UNSET
|
|
37
39
|
max_context_length: Optional[int] = 32768
|
|
@@ -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
|
+
GithubRepositoryInType = Literal["github"]
|
|
12
|
+
|
|
11
13
|
class GithubRepositoryInTypedDict(TypedDict):
|
|
12
14
|
name: str
|
|
13
15
|
owner: str
|
|
@@ -20,7 +22,7 @@ class GithubRepositoryIn(BaseModel):
|
|
|
20
22
|
name: str
|
|
21
23
|
owner: str
|
|
22
24
|
token: str
|
|
23
|
-
TYPE: Annotated[Final[Optional[
|
|
25
|
+
TYPE: Annotated[Final[Optional[GithubRepositoryInType]], pydantic.Field(alias="type")] = "github" # type: ignore
|
|
24
26
|
ref: OptionalNullable[str] = UNSET
|
|
25
27
|
weight: Optional[float] = 1
|
|
26
28
|
|
|
@@ -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
|
+
GithubRepositoryOutType = Literal["github"]
|
|
12
|
+
|
|
11
13
|
class GithubRepositoryOutTypedDict(TypedDict):
|
|
12
14
|
name: str
|
|
13
15
|
owner: str
|
|
@@ -20,7 +22,7 @@ class GithubRepositoryOut(BaseModel):
|
|
|
20
22
|
name: str
|
|
21
23
|
owner: str
|
|
22
24
|
commit_id: str
|
|
23
|
-
TYPE: Annotated[Final[Optional[
|
|
25
|
+
TYPE: Annotated[Final[Optional[GithubRepositoryOutType]], pydantic.Field(alias="type")] = "github" # type: ignore
|
|
24
26
|
ref: OptionalNullable[str] = UNSET
|
|
25
27
|
weight: Optional[float] = 1
|
|
26
28
|
|
mistralai/models/jobin.py
CHANGED
|
@@ -12,6 +12,18 @@ from typing import List, Optional, TypedDict
|
|
|
12
12
|
from typing_extensions import NotRequired
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
JobInIntegrationsTypedDict = WandbIntegrationTypedDict
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
JobInIntegrations = WandbIntegration
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
JobInRepositoriesTypedDict = GithubRepositoryInTypedDict
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
JobInRepositories = GithubRepositoryIn
|
|
25
|
+
|
|
26
|
+
|
|
15
27
|
class JobInTypedDict(TypedDict):
|
|
16
28
|
model: FineTuneableModel
|
|
17
29
|
r"""The name of the model to fine-tune."""
|
|
@@ -22,9 +34,9 @@ class JobInTypedDict(TypedDict):
|
|
|
22
34
|
r"""A list containing the IDs of uploaded files that contain validation data. If you provide these files, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in `checkpoints` when getting the status of a running fine-tuning job. The same data should not be present in both train and validation files."""
|
|
23
35
|
suffix: NotRequired[Nullable[str]]
|
|
24
36
|
r"""A string that will be added to your fine-tuning model name. For example, a suffix of \"my-great-model\" would produce a model name like `ft:open-mistral-7b:my-great-model:xxx...`"""
|
|
25
|
-
integrations: NotRequired[Nullable[List[
|
|
37
|
+
integrations: NotRequired[Nullable[List[JobInIntegrationsTypedDict]]]
|
|
26
38
|
r"""A list of integrations to enable for your fine-tuning job."""
|
|
27
|
-
repositories: NotRequired[List[
|
|
39
|
+
repositories: NotRequired[List[JobInRepositoriesTypedDict]]
|
|
28
40
|
auto_start: NotRequired[bool]
|
|
29
41
|
r"""This field will be required in a future release."""
|
|
30
42
|
|
|
@@ -39,9 +51,9 @@ class JobIn(BaseModel):
|
|
|
39
51
|
r"""A list containing the IDs of uploaded files that contain validation data. If you provide these files, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in `checkpoints` when getting the status of a running fine-tuning job. The same data should not be present in both train and validation files."""
|
|
40
52
|
suffix: OptionalNullable[str] = UNSET
|
|
41
53
|
r"""A string that will be added to your fine-tuning model name. For example, a suffix of \"my-great-model\" would produce a model name like `ft:open-mistral-7b:my-great-model:xxx...`"""
|
|
42
|
-
integrations: OptionalNullable[List[
|
|
54
|
+
integrations: OptionalNullable[List[JobInIntegrations]] = UNSET
|
|
43
55
|
r"""A list of integrations to enable for your fine-tuning job."""
|
|
44
|
-
repositories: Optional[List[
|
|
56
|
+
repositories: Optional[List[JobInRepositories]] = None
|
|
45
57
|
auto_start: Optional[bool] = None
|
|
46
58
|
r"""This field will be required in a future release."""
|
|
47
59
|
|
mistralai/models/jobout.py
CHANGED
|
@@ -16,6 +16,21 @@ from typing_extensions import Annotated, NotRequired
|
|
|
16
16
|
Status = Literal["QUEUED", "STARTED", "VALIDATING", "VALIDATED", "RUNNING", "FAILED_VALIDATION", "FAILED", "SUCCESS", "CANCELLED", "CANCELLATION_REQUESTED"]
|
|
17
17
|
r"""The current status of the fine-tuning job."""
|
|
18
18
|
|
|
19
|
+
Object = Literal["job"]
|
|
20
|
+
r"""The object type of the fine-tuning job."""
|
|
21
|
+
|
|
22
|
+
IntegrationsTypedDict = WandbIntegrationOutTypedDict
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Integrations = WandbIntegrationOut
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
RepositoriesTypedDict = GithubRepositoryOutTypedDict
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
Repositories = GithubRepositoryOut
|
|
32
|
+
|
|
33
|
+
|
|
19
34
|
class JobOutTypedDict(TypedDict):
|
|
20
35
|
id: str
|
|
21
36
|
r"""The ID of the job."""
|
|
@@ -39,11 +54,11 @@ class JobOutTypedDict(TypedDict):
|
|
|
39
54
|
r"""The name of the fine-tuned model that is being created. The value will be `null` if the fine-tuning job is still running."""
|
|
40
55
|
suffix: NotRequired[Nullable[str]]
|
|
41
56
|
r"""Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`."""
|
|
42
|
-
integrations: NotRequired[Nullable[List[
|
|
57
|
+
integrations: NotRequired[Nullable[List[IntegrationsTypedDict]]]
|
|
43
58
|
r"""A list of integrations enabled for your fine-tuning job."""
|
|
44
59
|
trained_tokens: NotRequired[Nullable[int]]
|
|
45
60
|
r"""Total number of tokens trained."""
|
|
46
|
-
repositories: NotRequired[List[
|
|
61
|
+
repositories: NotRequired[List[RepositoriesTypedDict]]
|
|
47
62
|
metadata: NotRequired[Nullable[JobMetadataOutTypedDict]]
|
|
48
63
|
|
|
49
64
|
|
|
@@ -66,17 +81,17 @@ class JobOut(BaseModel):
|
|
|
66
81
|
r"""A list containing the IDs of uploaded files that contain training data."""
|
|
67
82
|
validation_files: OptionalNullable[List[str]] = UNSET
|
|
68
83
|
r"""A list containing the IDs of uploaded files that contain validation data."""
|
|
69
|
-
OBJECT: Annotated[Final[Optional[
|
|
84
|
+
OBJECT: Annotated[Final[Optional[Object]], pydantic.Field(alias="object")] = "job" # type: ignore
|
|
70
85
|
r"""The object type of the fine-tuning job."""
|
|
71
86
|
fine_tuned_model: OptionalNullable[str] = UNSET
|
|
72
87
|
r"""The name of the fine-tuned model that is being created. The value will be `null` if the fine-tuning job is still running."""
|
|
73
88
|
suffix: OptionalNullable[str] = UNSET
|
|
74
89
|
r"""Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`."""
|
|
75
|
-
integrations: OptionalNullable[List[
|
|
90
|
+
integrations: OptionalNullable[List[Integrations]] = UNSET
|
|
76
91
|
r"""A list of integrations enabled for your fine-tuning job."""
|
|
77
92
|
trained_tokens: OptionalNullable[int] = UNSET
|
|
78
93
|
r"""Total number of tokens trained."""
|
|
79
|
-
repositories: Optional[List[
|
|
94
|
+
repositories: Optional[List[Repositories]] = None
|
|
80
95
|
metadata: OptionalNullable[JobMetadataOut] = UNSET
|
|
81
96
|
|
|
82
97
|
@model_serializer(mode="wrap")
|
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):
|
|
@@ -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
|
|
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
|
|
|
@@ -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/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.3"
|
|
33
|
+
gen_version: str = "2.404.11"
|
|
34
|
+
user_agent: str = "speakeasy-sdk/python 1.0.3 2.404.11 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",
|