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
|
@@ -5,13 +5,15 @@ from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
|
|
5
5
|
from .responseformat import ResponseFormat, ResponseFormatTypedDict
|
|
6
6
|
from .systemmessage import SystemMessage, SystemMessageTypedDict
|
|
7
7
|
from .tool import Tool, ToolTypedDict
|
|
8
|
+
from .toolchoice import ToolChoice, ToolChoiceTypedDict
|
|
9
|
+
from .toolchoiceenum import ToolChoiceEnum
|
|
8
10
|
from .toolmessage import ToolMessage, ToolMessageTypedDict
|
|
9
11
|
from .usermessage import UserMessage, UserMessageTypedDict
|
|
10
12
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
11
13
|
from mistralai.utils import get_discriminator
|
|
12
14
|
from pydantic import Discriminator, Tag, model_serializer
|
|
13
|
-
from typing import List,
|
|
14
|
-
from typing_extensions import Annotated, NotRequired
|
|
15
|
+
from typing import List, Optional, Union
|
|
16
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
ChatCompletionStreamRequestStopTypedDict = Union[str, List[str]]
|
|
@@ -22,27 +24,44 @@ ChatCompletionStreamRequestStop = Union[str, List[str]]
|
|
|
22
24
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
23
25
|
|
|
24
26
|
|
|
25
|
-
ChatCompletionStreamRequestMessagesTypedDict = Union[
|
|
27
|
+
ChatCompletionStreamRequestMessagesTypedDict = Union[
|
|
28
|
+
SystemMessageTypedDict,
|
|
29
|
+
UserMessageTypedDict,
|
|
30
|
+
AssistantMessageTypedDict,
|
|
31
|
+
ToolMessageTypedDict,
|
|
32
|
+
]
|
|
26
33
|
|
|
27
34
|
|
|
28
|
-
ChatCompletionStreamRequestMessages = Annotated[
|
|
35
|
+
ChatCompletionStreamRequestMessages = Annotated[
|
|
36
|
+
Union[
|
|
37
|
+
Annotated[AssistantMessage, Tag("assistant")],
|
|
38
|
+
Annotated[SystemMessage, Tag("system")],
|
|
39
|
+
Annotated[ToolMessage, Tag("tool")],
|
|
40
|
+
Annotated[UserMessage, Tag("user")],
|
|
41
|
+
],
|
|
42
|
+
Discriminator(lambda m: get_discriminator(m, "role", "role")),
|
|
43
|
+
]
|
|
29
44
|
|
|
30
45
|
|
|
31
|
-
|
|
46
|
+
ChatCompletionStreamRequestToolChoiceTypedDict = Union[
|
|
47
|
+
ToolChoiceTypedDict, ToolChoiceEnum
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
ChatCompletionStreamRequestToolChoice = Union[ToolChoice, ToolChoiceEnum]
|
|
52
|
+
|
|
32
53
|
|
|
33
54
|
class ChatCompletionStreamRequestTypedDict(TypedDict):
|
|
34
55
|
model: Nullable[str]
|
|
35
56
|
r"""ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions."""
|
|
36
57
|
messages: List[ChatCompletionStreamRequestMessagesTypedDict]
|
|
37
58
|
r"""The prompt(s) to generate completions for, encoded as a list of dict with role and content."""
|
|
38
|
-
temperature: NotRequired[float]
|
|
39
|
-
r"""What sampling temperature to use, between 0.0 and
|
|
59
|
+
temperature: NotRequired[Nullable[float]]
|
|
60
|
+
r"""What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value."""
|
|
40
61
|
top_p: NotRequired[float]
|
|
41
62
|
r"""Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both."""
|
|
42
63
|
max_tokens: NotRequired[Nullable[int]]
|
|
43
64
|
r"""The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length."""
|
|
44
|
-
min_tokens: NotRequired[Nullable[int]]
|
|
45
|
-
r"""The minimum number of tokens to generate in the completion."""
|
|
46
65
|
stream: NotRequired[bool]
|
|
47
66
|
stop: NotRequired[ChatCompletionStreamRequestStopTypedDict]
|
|
48
67
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
@@ -50,39 +69,84 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
|
|
|
50
69
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
51
70
|
response_format: NotRequired[ResponseFormatTypedDict]
|
|
52
71
|
tools: NotRequired[Nullable[List[ToolTypedDict]]]
|
|
53
|
-
tool_choice: NotRequired[
|
|
72
|
+
tool_choice: NotRequired[ChatCompletionStreamRequestToolChoiceTypedDict]
|
|
73
|
+
presence_penalty: NotRequired[float]
|
|
74
|
+
r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
|
|
75
|
+
frequency_penalty: NotRequired[float]
|
|
76
|
+
r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
|
|
77
|
+
n: NotRequired[Nullable[int]]
|
|
78
|
+
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
54
79
|
safe_prompt: NotRequired[bool]
|
|
55
80
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
56
|
-
|
|
81
|
+
|
|
57
82
|
|
|
58
83
|
class ChatCompletionStreamRequest(BaseModel):
|
|
59
84
|
model: Nullable[str]
|
|
60
85
|
r"""ID of the model to use. You can use the [List Available Models](/api/#tag/models/operation/list_models_v1_models_get) API to see all of your available models, or see our [Model overview](/models) for model descriptions."""
|
|
86
|
+
|
|
61
87
|
messages: List[ChatCompletionStreamRequestMessages]
|
|
62
88
|
r"""The prompt(s) to generate completions for, encoded as a list of dict with role and content."""
|
|
63
|
-
|
|
64
|
-
|
|
89
|
+
|
|
90
|
+
temperature: OptionalNullable[float] = UNSET
|
|
91
|
+
r"""What sampling temperature to use, we recommend between 0.0 and 0.7. Higher values like 0.7 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. The default value varies depending on the model you are targeting. Call the `/models` endpoint to retrieve the appropriate value."""
|
|
92
|
+
|
|
65
93
|
top_p: Optional[float] = 1
|
|
66
94
|
r"""Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both."""
|
|
95
|
+
|
|
67
96
|
max_tokens: OptionalNullable[int] = UNSET
|
|
68
97
|
r"""The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length."""
|
|
69
|
-
|
|
70
|
-
r"""The minimum number of tokens to generate in the completion."""
|
|
98
|
+
|
|
71
99
|
stream: Optional[bool] = True
|
|
100
|
+
|
|
72
101
|
stop: Optional[ChatCompletionStreamRequestStop] = None
|
|
73
102
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
103
|
+
|
|
74
104
|
random_seed: OptionalNullable[int] = UNSET
|
|
75
105
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
106
|
+
|
|
76
107
|
response_format: Optional[ResponseFormat] = None
|
|
108
|
+
|
|
77
109
|
tools: OptionalNullable[List[Tool]] = UNSET
|
|
78
|
-
|
|
110
|
+
|
|
111
|
+
tool_choice: Optional[ChatCompletionStreamRequestToolChoice] = None
|
|
112
|
+
|
|
113
|
+
presence_penalty: Optional[float] = 0
|
|
114
|
+
r"""presence_penalty determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative."""
|
|
115
|
+
|
|
116
|
+
frequency_penalty: Optional[float] = 0
|
|
117
|
+
r"""frequency_penalty penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition."""
|
|
118
|
+
|
|
119
|
+
n: OptionalNullable[int] = UNSET
|
|
120
|
+
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
121
|
+
|
|
79
122
|
safe_prompt: Optional[bool] = False
|
|
80
123
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
81
|
-
|
|
124
|
+
|
|
82
125
|
@model_serializer(mode="wrap")
|
|
83
126
|
def serialize_model(self, handler):
|
|
84
|
-
optional_fields = [
|
|
85
|
-
|
|
127
|
+
optional_fields = [
|
|
128
|
+
"temperature",
|
|
129
|
+
"top_p",
|
|
130
|
+
"max_tokens",
|
|
131
|
+
"stream",
|
|
132
|
+
"stop",
|
|
133
|
+
"random_seed",
|
|
134
|
+
"response_format",
|
|
135
|
+
"tools",
|
|
136
|
+
"tool_choice",
|
|
137
|
+
"presence_penalty",
|
|
138
|
+
"frequency_penalty",
|
|
139
|
+
"n",
|
|
140
|
+
"safe_prompt",
|
|
141
|
+
]
|
|
142
|
+
nullable_fields = [
|
|
143
|
+
"model",
|
|
144
|
+
"temperature",
|
|
145
|
+
"max_tokens",
|
|
146
|
+
"random_seed",
|
|
147
|
+
"tools",
|
|
148
|
+
"n",
|
|
149
|
+
]
|
|
86
150
|
null_default_fields = []
|
|
87
151
|
|
|
88
152
|
serialized = handler(self)
|
|
@@ -92,9 +156,13 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
92
156
|
for n, f in self.model_fields.items():
|
|
93
157
|
k = f.alias or n
|
|
94
158
|
val = serialized.get(k)
|
|
159
|
+
serialized.pop(k, None)
|
|
95
160
|
|
|
96
161
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
97
|
-
is_set = (
|
|
162
|
+
is_set = (
|
|
163
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
164
|
+
or k in null_default_fields
|
|
165
|
+
) # pylint: disable=no-member
|
|
98
166
|
|
|
99
167
|
if val is not None and val != UNSET_SENTINEL:
|
|
100
168
|
m[k] = val
|
|
@@ -104,4 +172,3 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
104
172
|
m[k] = val
|
|
105
173
|
|
|
106
174
|
return m
|
|
107
|
-
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .metricout import MetricOut, MetricOutTypedDict
|
|
5
5
|
from mistralai.types import BaseModel
|
|
6
|
-
from
|
|
6
|
+
from typing_extensions import TypedDict
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class CheckpointOutTypedDict(TypedDict):
|
|
@@ -13,13 +13,14 @@ class CheckpointOutTypedDict(TypedDict):
|
|
|
13
13
|
r"""The step number that the checkpoint was created at."""
|
|
14
14
|
created_at: int
|
|
15
15
|
r"""The UNIX timestamp (in seconds) for when the checkpoint was created."""
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
|
|
18
18
|
class CheckpointOut(BaseModel):
|
|
19
19
|
metrics: MetricOut
|
|
20
20
|
r"""Metrics at the step number during the fine-tuning job. Use these metrics to assess if the training is going smoothly (loss should decrease, token accuracy should increase)."""
|
|
21
|
+
|
|
21
22
|
step_number: int
|
|
22
23
|
r"""The step number that the checkpoint was created at."""
|
|
24
|
+
|
|
23
25
|
created_at: int
|
|
24
26
|
r"""The UNIX timestamp (in seconds) for when the checkpoint was created."""
|
|
25
|
-
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai.types import BaseModel
|
|
5
|
+
from typing import Dict, Optional
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ClassificationObjectTypedDict(TypedDict):
|
|
10
|
+
categories: NotRequired[Dict[str, bool]]
|
|
11
|
+
r"""Classifier result thresholded"""
|
|
12
|
+
category_scores: NotRequired[Dict[str, float]]
|
|
13
|
+
r"""Classifier result"""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ClassificationObject(BaseModel):
|
|
17
|
+
categories: Optional[Dict[str, bool]] = None
|
|
18
|
+
r"""Classifier result thresholded"""
|
|
19
|
+
|
|
20
|
+
category_scores: Optional[Dict[str, float]] = None
|
|
21
|
+
r"""Classifier result"""
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
5
|
+
import pydantic
|
|
6
|
+
from pydantic import model_serializer
|
|
7
|
+
from typing import List, Union
|
|
8
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
ClassificationRequestInputsTypedDict = Union[str, List[str]]
|
|
12
|
+
r"""Text to classify."""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
ClassificationRequestInputs = Union[str, List[str]]
|
|
16
|
+
r"""Text to classify."""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ClassificationRequestTypedDict(TypedDict):
|
|
20
|
+
inputs: ClassificationRequestInputsTypedDict
|
|
21
|
+
r"""Text to classify."""
|
|
22
|
+
model: NotRequired[Nullable[str]]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ClassificationRequest(BaseModel):
|
|
26
|
+
inputs: Annotated[ClassificationRequestInputs, pydantic.Field(alias="input")]
|
|
27
|
+
r"""Text to classify."""
|
|
28
|
+
|
|
29
|
+
model: OptionalNullable[str] = UNSET
|
|
30
|
+
|
|
31
|
+
@model_serializer(mode="wrap")
|
|
32
|
+
def serialize_model(self, handler):
|
|
33
|
+
optional_fields = ["model"]
|
|
34
|
+
nullable_fields = ["model"]
|
|
35
|
+
null_default_fields = []
|
|
36
|
+
|
|
37
|
+
serialized = handler(self)
|
|
38
|
+
|
|
39
|
+
m = {}
|
|
40
|
+
|
|
41
|
+
for n, f in self.model_fields.items():
|
|
42
|
+
k = f.alias or n
|
|
43
|
+
val = serialized.get(k)
|
|
44
|
+
serialized.pop(k, None)
|
|
45
|
+
|
|
46
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
47
|
+
is_set = (
|
|
48
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
49
|
+
or k in null_default_fields
|
|
50
|
+
) # 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
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .classificationobject import ClassificationObject, ClassificationObjectTypedDict
|
|
5
|
+
from mistralai.types import BaseModel
|
|
6
|
+
from typing import List, Optional
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ClassificationResponseTypedDict(TypedDict):
|
|
11
|
+
id: NotRequired[str]
|
|
12
|
+
model: NotRequired[str]
|
|
13
|
+
results: NotRequired[List[ClassificationObjectTypedDict]]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ClassificationResponse(BaseModel):
|
|
17
|
+
id: Optional[str] = None
|
|
18
|
+
|
|
19
|
+
model: Optional[str] = None
|
|
20
|
+
|
|
21
|
+
results: Optional[List[ClassificationObject]] = None
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from .completionresponsestreamchoice import
|
|
4
|
+
from .completionresponsestreamchoice import (
|
|
5
|
+
CompletionResponseStreamChoice,
|
|
6
|
+
CompletionResponseStreamChoiceTypedDict,
|
|
7
|
+
)
|
|
5
8
|
from .usageinfo import UsageInfo, UsageInfoTypedDict
|
|
6
9
|
from mistralai.types import BaseModel
|
|
7
|
-
from typing import List, Optional
|
|
8
|
-
from typing_extensions import NotRequired
|
|
10
|
+
from typing import List, Optional
|
|
11
|
+
from typing_extensions import NotRequired, TypedDict
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
class CompletionChunkTypedDict(TypedDict):
|
|
@@ -15,13 +18,17 @@ class CompletionChunkTypedDict(TypedDict):
|
|
|
15
18
|
object: NotRequired[str]
|
|
16
19
|
created: NotRequired[int]
|
|
17
20
|
usage: NotRequired[UsageInfoTypedDict]
|
|
18
|
-
|
|
21
|
+
|
|
19
22
|
|
|
20
23
|
class CompletionChunk(BaseModel):
|
|
21
24
|
id: str
|
|
25
|
+
|
|
22
26
|
model: str
|
|
27
|
+
|
|
23
28
|
choices: List[CompletionResponseStreamChoice]
|
|
29
|
+
|
|
24
30
|
object: Optional[str] = None
|
|
31
|
+
|
|
25
32
|
created: Optional[int] = None
|
|
33
|
+
|
|
26
34
|
usage: Optional[UsageInfo] = None
|
|
27
|
-
|
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .completionchunk import CompletionChunk, CompletionChunkTypedDict
|
|
5
5
|
from mistralai.types import BaseModel
|
|
6
|
-
from
|
|
6
|
+
from typing_extensions import TypedDict
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class CompletionEventTypedDict(TypedDict):
|
|
10
10
|
data: CompletionChunkTypedDict
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
|
|
13
13
|
class CompletionEvent(BaseModel):
|
|
14
14
|
data: CompletionChunk
|
|
15
|
-
|
|
@@ -2,24 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .deltamessage import DeltaMessage, DeltaMessageTypedDict
|
|
5
|
-
from mistralai.types import BaseModel, Nullable, UNSET_SENTINEL
|
|
5
|
+
from mistralai.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
|
|
6
|
+
from mistralai.utils import validate_open_enum
|
|
6
7
|
from pydantic import model_serializer
|
|
7
|
-
from
|
|
8
|
+
from pydantic.functional_validators import PlainValidator
|
|
9
|
+
from typing import Literal, Union
|
|
10
|
+
from typing_extensions import Annotated, TypedDict
|
|
8
11
|
|
|
9
12
|
|
|
10
|
-
CompletionResponseStreamChoiceFinishReason =
|
|
13
|
+
CompletionResponseStreamChoiceFinishReason = Union[
|
|
14
|
+
Literal["stop", "length", "error", "tool_calls"], UnrecognizedStr
|
|
15
|
+
]
|
|
16
|
+
|
|
11
17
|
|
|
12
18
|
class CompletionResponseStreamChoiceTypedDict(TypedDict):
|
|
13
19
|
index: int
|
|
14
20
|
delta: DeltaMessageTypedDict
|
|
15
21
|
finish_reason: Nullable[CompletionResponseStreamChoiceFinishReason]
|
|
16
|
-
|
|
22
|
+
|
|
17
23
|
|
|
18
24
|
class CompletionResponseStreamChoice(BaseModel):
|
|
19
25
|
index: int
|
|
26
|
+
|
|
20
27
|
delta: DeltaMessage
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
|
|
29
|
+
finish_reason: Annotated[
|
|
30
|
+
Nullable[CompletionResponseStreamChoiceFinishReason],
|
|
31
|
+
PlainValidator(validate_open_enum(False)),
|
|
32
|
+
]
|
|
33
|
+
|
|
23
34
|
@model_serializer(mode="wrap")
|
|
24
35
|
def serialize_model(self, handler):
|
|
25
36
|
optional_fields = []
|
|
@@ -33,9 +44,13 @@ class CompletionResponseStreamChoice(BaseModel):
|
|
|
33
44
|
for n, f in self.model_fields.items():
|
|
34
45
|
k = f.alias or n
|
|
35
46
|
val = serialized.get(k)
|
|
47
|
+
serialized.pop(k, None)
|
|
36
48
|
|
|
37
49
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
38
|
-
is_set = (
|
|
50
|
+
is_set = (
|
|
51
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
52
|
+
or k in null_default_fields
|
|
53
|
+
) # pylint: disable=no-member
|
|
39
54
|
|
|
40
55
|
if val is not None and val != UNSET_SENTINEL:
|
|
41
56
|
m[k] = val
|
|
@@ -45,4 +60,3 @@ class CompletionResponseStreamChoice(BaseModel):
|
|
|
45
60
|
m[k] = val
|
|
46
61
|
|
|
47
62
|
return m
|
|
48
|
-
|
mistralai/models/contentchunk.py
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from
|
|
5
|
-
import
|
|
6
|
-
from
|
|
4
|
+
from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
|
|
5
|
+
from .textchunk import TextChunk, TextChunkTypedDict
|
|
6
|
+
from mistralai.utils import get_discriminator
|
|
7
|
+
from pydantic import Discriminator, Tag
|
|
8
|
+
from typing import Union
|
|
7
9
|
from typing_extensions import Annotated
|
|
8
10
|
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
text: str
|
|
12
|
-
|
|
12
|
+
ContentChunkTypedDict = Union[TextChunkTypedDict, ImageURLChunkTypedDict]
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
|
|
15
|
+
ContentChunk = Annotated[
|
|
16
|
+
Union[
|
|
17
|
+
Annotated[ImageURLChunk, Tag("image_url")], Annotated[TextChunk, Tag("text")]
|
|
18
|
+
],
|
|
19
|
+
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
20
|
+
]
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
5
|
from mistralai.utils import FieldMetadata, PathParamMetadata
|
|
6
|
-
from
|
|
7
|
-
from typing_extensions import Annotated
|
|
6
|
+
from typing_extensions import Annotated, TypedDict
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class DeleteModelV1ModelsModelIDDeleteRequestTypedDict(TypedDict):
|
|
11
10
|
model_id: str
|
|
12
11
|
r"""The ID of the model to delete."""
|
|
13
|
-
|
|
12
|
+
|
|
14
13
|
|
|
15
14
|
class DeleteModelV1ModelsModelIDDeleteRequest(BaseModel):
|
|
16
|
-
model_id: Annotated[
|
|
15
|
+
model_id: Annotated[
|
|
16
|
+
str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
|
|
17
|
+
]
|
|
17
18
|
r"""The ID of the model to delete."""
|
|
18
|
-
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
|
-
from
|
|
5
|
+
from typing_extensions import TypedDict
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class DeleteFileOutTypedDict(TypedDict):
|
|
@@ -12,13 +12,14 @@ class DeleteFileOutTypedDict(TypedDict):
|
|
|
12
12
|
r"""The object type that was deleted"""
|
|
13
13
|
deleted: bool
|
|
14
14
|
r"""The deletion status."""
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
|
|
17
17
|
class DeleteFileOut(BaseModel):
|
|
18
18
|
id: str
|
|
19
19
|
r"""The ID of the deleted file."""
|
|
20
|
+
|
|
20
21
|
object: str
|
|
21
22
|
r"""The object type that was deleted"""
|
|
23
|
+
|
|
22
24
|
deleted: bool
|
|
23
25
|
r"""The deletion status."""
|
|
24
|
-
|
|
@@ -2,8 +2,8 @@
|
|
|
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 DeleteModelOutTypedDict(TypedDict):
|
|
@@ -13,13 +13,14 @@ class DeleteModelOutTypedDict(TypedDict):
|
|
|
13
13
|
r"""The object type that was deleted"""
|
|
14
14
|
deleted: NotRequired[bool]
|
|
15
15
|
r"""The deletion status"""
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
|
|
18
18
|
class DeleteModelOut(BaseModel):
|
|
19
19
|
id: str
|
|
20
20
|
r"""The ID of the deleted model."""
|
|
21
|
+
|
|
21
22
|
object: Optional[str] = "model"
|
|
22
23
|
r"""The object type that was deleted"""
|
|
24
|
+
|
|
23
25
|
deleted: Optional[bool] = True
|
|
24
26
|
r"""The deletion status"""
|
|
25
|
-
|
mistralai/models/deltamessage.py
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
+
from .contentchunk import ContentChunk, ContentChunkTypedDict
|
|
4
5
|
from .toolcall import ToolCall, ToolCallTypedDict
|
|
5
6
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
6
7
|
from pydantic import model_serializer
|
|
7
|
-
from typing import List,
|
|
8
|
-
from typing_extensions import NotRequired
|
|
8
|
+
from typing import List, Union
|
|
9
|
+
from typing_extensions import NotRequired, TypedDict
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
ContentTypedDict = Union[str, List[ContentChunkTypedDict]]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Content = Union[str, List[ContentChunk]]
|
|
9
16
|
|
|
10
17
|
|
|
11
18
|
class DeltaMessageTypedDict(TypedDict):
|
|
12
|
-
role: NotRequired[str]
|
|
13
|
-
content: NotRequired[Nullable[
|
|
19
|
+
role: NotRequired[Nullable[str]]
|
|
20
|
+
content: NotRequired[Nullable[ContentTypedDict]]
|
|
14
21
|
tool_calls: NotRequired[Nullable[List[ToolCallTypedDict]]]
|
|
15
|
-
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
class DeltaMessage(BaseModel):
|
|
18
|
-
role:
|
|
19
|
-
|
|
25
|
+
role: OptionalNullable[str] = UNSET
|
|
26
|
+
|
|
27
|
+
content: OptionalNullable[Content] = UNSET
|
|
28
|
+
|
|
20
29
|
tool_calls: OptionalNullable[List[ToolCall]] = UNSET
|
|
21
|
-
|
|
30
|
+
|
|
22
31
|
@model_serializer(mode="wrap")
|
|
23
32
|
def serialize_model(self, handler):
|
|
24
33
|
optional_fields = ["role", "content", "tool_calls"]
|
|
25
|
-
nullable_fields = ["content", "tool_calls"]
|
|
34
|
+
nullable_fields = ["role", "content", "tool_calls"]
|
|
26
35
|
null_default_fields = []
|
|
27
36
|
|
|
28
37
|
serialized = handler(self)
|
|
@@ -32,9 +41,13 @@ class DeltaMessage(BaseModel):
|
|
|
32
41
|
for n, f in self.model_fields.items():
|
|
33
42
|
k = f.alias or n
|
|
34
43
|
val = serialized.get(k)
|
|
44
|
+
serialized.pop(k, None)
|
|
35
45
|
|
|
36
46
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
37
|
-
is_set = (
|
|
47
|
+
is_set = (
|
|
48
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
49
|
+
or k in null_default_fields
|
|
50
|
+
) # pylint: disable=no-member
|
|
38
51
|
|
|
39
52
|
if val is not None and val != UNSET_SENTINEL:
|
|
40
53
|
m[k] = val
|
|
@@ -44,4 +57,3 @@ class DeltaMessage(BaseModel):
|
|
|
44
57
|
m[k] = val
|
|
45
58
|
|
|
46
59
|
return m
|
|
47
|
-
|