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
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
|
5
5
|
from .responseformat import ResponseFormat, ResponseFormatTypedDict
|
|
6
|
+
from .systemmessage import SystemMessage, SystemMessageTypedDict
|
|
6
7
|
from .tool import Tool, ToolTypedDict
|
|
8
|
+
from .toolchoice import ToolChoice, ToolChoiceTypedDict
|
|
9
|
+
from .toolchoiceenum import ToolChoiceEnum
|
|
7
10
|
from .toolmessage import ToolMessage, ToolMessageTypedDict
|
|
8
11
|
from .usermessage import UserMessage, UserMessageTypedDict
|
|
9
12
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
10
13
|
from mistralai.utils import get_discriminator
|
|
11
14
|
from pydantic import Discriminator, Tag, model_serializer
|
|
12
|
-
from typing import List,
|
|
13
|
-
from typing_extensions import Annotated, NotRequired
|
|
15
|
+
from typing import List, Optional, Union
|
|
16
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
AgentsCompletionRequestStopTypedDict = Union[str, List[str]]
|
|
@@ -21,13 +24,30 @@ AgentsCompletionRequestStop = Union[str, List[str]]
|
|
|
21
24
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
22
25
|
|
|
23
26
|
|
|
24
|
-
AgentsCompletionRequestMessagesTypedDict = Union[
|
|
27
|
+
AgentsCompletionRequestMessagesTypedDict = Union[
|
|
28
|
+
SystemMessageTypedDict,
|
|
29
|
+
UserMessageTypedDict,
|
|
30
|
+
AssistantMessageTypedDict,
|
|
31
|
+
ToolMessageTypedDict,
|
|
32
|
+
]
|
|
25
33
|
|
|
26
34
|
|
|
27
|
-
AgentsCompletionRequestMessages = Annotated[
|
|
35
|
+
AgentsCompletionRequestMessages = 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
|
+
]
|
|
28
44
|
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
AgentsCompletionRequestToolChoiceTypedDict = Union[ToolChoiceTypedDict, ToolChoiceEnum]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
AgentsCompletionRequestToolChoice = Union[ToolChoice, ToolChoiceEnum]
|
|
50
|
+
|
|
31
51
|
|
|
32
52
|
class AgentsCompletionRequestTypedDict(TypedDict):
|
|
33
53
|
messages: List[AgentsCompletionRequestMessagesTypedDict]
|
|
@@ -36,8 +56,6 @@ class AgentsCompletionRequestTypedDict(TypedDict):
|
|
|
36
56
|
r"""The ID of the agent to use for this completion."""
|
|
37
57
|
max_tokens: NotRequired[Nullable[int]]
|
|
38
58
|
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."""
|
|
39
|
-
min_tokens: NotRequired[Nullable[int]]
|
|
40
|
-
r"""The minimum number of tokens to generate in the completion."""
|
|
41
59
|
stream: NotRequired[bool]
|
|
42
60
|
r"""Whether to stream back partial progress. If set, tokens will be sent as data-only server-side events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON."""
|
|
43
61
|
stop: NotRequired[AgentsCompletionRequestStopTypedDict]
|
|
@@ -46,32 +64,64 @@ class AgentsCompletionRequestTypedDict(TypedDict):
|
|
|
46
64
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
47
65
|
response_format: NotRequired[ResponseFormatTypedDict]
|
|
48
66
|
tools: NotRequired[Nullable[List[ToolTypedDict]]]
|
|
49
|
-
tool_choice: NotRequired[
|
|
50
|
-
|
|
67
|
+
tool_choice: NotRequired[AgentsCompletionRequestToolChoiceTypedDict]
|
|
68
|
+
presence_penalty: NotRequired[float]
|
|
69
|
+
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."""
|
|
70
|
+
frequency_penalty: NotRequired[float]
|
|
71
|
+
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."""
|
|
72
|
+
n: NotRequired[Nullable[int]]
|
|
73
|
+
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
74
|
+
|
|
51
75
|
|
|
52
76
|
class AgentsCompletionRequest(BaseModel):
|
|
53
77
|
messages: List[AgentsCompletionRequestMessages]
|
|
54
78
|
r"""The prompt(s) to generate completions for, encoded as a list of dict with role and content."""
|
|
79
|
+
|
|
55
80
|
agent_id: str
|
|
56
81
|
r"""The ID of the agent to use for this completion."""
|
|
82
|
+
|
|
57
83
|
max_tokens: OptionalNullable[int] = UNSET
|
|
58
84
|
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."""
|
|
59
|
-
|
|
60
|
-
r"""The minimum number of tokens to generate in the completion."""
|
|
85
|
+
|
|
61
86
|
stream: Optional[bool] = False
|
|
62
87
|
r"""Whether to stream back partial progress. If set, tokens will be sent as data-only server-side events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON."""
|
|
88
|
+
|
|
63
89
|
stop: Optional[AgentsCompletionRequestStop] = None
|
|
64
90
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
91
|
+
|
|
65
92
|
random_seed: OptionalNullable[int] = UNSET
|
|
66
93
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
94
|
+
|
|
67
95
|
response_format: Optional[ResponseFormat] = None
|
|
96
|
+
|
|
68
97
|
tools: OptionalNullable[List[Tool]] = UNSET
|
|
69
|
-
|
|
70
|
-
|
|
98
|
+
|
|
99
|
+
tool_choice: Optional[AgentsCompletionRequestToolChoice] = None
|
|
100
|
+
|
|
101
|
+
presence_penalty: Optional[float] = 0
|
|
102
|
+
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."""
|
|
103
|
+
|
|
104
|
+
frequency_penalty: Optional[float] = 0
|
|
105
|
+
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."""
|
|
106
|
+
|
|
107
|
+
n: OptionalNullable[int] = UNSET
|
|
108
|
+
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
109
|
+
|
|
71
110
|
@model_serializer(mode="wrap")
|
|
72
111
|
def serialize_model(self, handler):
|
|
73
|
-
optional_fields = [
|
|
74
|
-
|
|
112
|
+
optional_fields = [
|
|
113
|
+
"max_tokens",
|
|
114
|
+
"stream",
|
|
115
|
+
"stop",
|
|
116
|
+
"random_seed",
|
|
117
|
+
"response_format",
|
|
118
|
+
"tools",
|
|
119
|
+
"tool_choice",
|
|
120
|
+
"presence_penalty",
|
|
121
|
+
"frequency_penalty",
|
|
122
|
+
"n",
|
|
123
|
+
]
|
|
124
|
+
nullable_fields = ["max_tokens", "random_seed", "tools", "n"]
|
|
75
125
|
null_default_fields = []
|
|
76
126
|
|
|
77
127
|
serialized = handler(self)
|
|
@@ -81,9 +131,13 @@ class AgentsCompletionRequest(BaseModel):
|
|
|
81
131
|
for n, f in self.model_fields.items():
|
|
82
132
|
k = f.alias or n
|
|
83
133
|
val = serialized.get(k)
|
|
134
|
+
serialized.pop(k, None)
|
|
84
135
|
|
|
85
136
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
86
|
-
is_set = (
|
|
137
|
+
is_set = (
|
|
138
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
139
|
+
or k in null_default_fields
|
|
140
|
+
) # pylint: disable=no-member
|
|
87
141
|
|
|
88
142
|
if val is not None and val != UNSET_SENTINEL:
|
|
89
143
|
m[k] = val
|
|
@@ -93,4 +147,3 @@ class AgentsCompletionRequest(BaseModel):
|
|
|
93
147
|
m[k] = val
|
|
94
148
|
|
|
95
149
|
return m
|
|
96
|
-
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
|
5
5
|
from .responseformat import ResponseFormat, ResponseFormatTypedDict
|
|
6
|
+
from .systemmessage import SystemMessage, SystemMessageTypedDict
|
|
6
7
|
from .tool import Tool, ToolTypedDict
|
|
8
|
+
from .toolchoice import ToolChoice, ToolChoiceTypedDict
|
|
9
|
+
from .toolchoiceenum import ToolChoiceEnum
|
|
7
10
|
from .toolmessage import ToolMessage, ToolMessageTypedDict
|
|
8
11
|
from .usermessage import UserMessage, UserMessageTypedDict
|
|
9
12
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
10
13
|
from mistralai.utils import get_discriminator
|
|
11
14
|
from pydantic import Discriminator, Tag, model_serializer
|
|
12
|
-
from typing import List,
|
|
13
|
-
from typing_extensions import Annotated, NotRequired
|
|
15
|
+
from typing import List, Optional, Union
|
|
16
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
AgentsCompletionStreamRequestStopTypedDict = Union[str, List[str]]
|
|
@@ -21,13 +24,32 @@ AgentsCompletionStreamRequestStop = Union[str, List[str]]
|
|
|
21
24
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
22
25
|
|
|
23
26
|
|
|
24
|
-
AgentsCompletionStreamRequestMessagesTypedDict = Union[
|
|
27
|
+
AgentsCompletionStreamRequestMessagesTypedDict = Union[
|
|
28
|
+
SystemMessageTypedDict,
|
|
29
|
+
UserMessageTypedDict,
|
|
30
|
+
AssistantMessageTypedDict,
|
|
31
|
+
ToolMessageTypedDict,
|
|
32
|
+
]
|
|
25
33
|
|
|
26
34
|
|
|
27
|
-
AgentsCompletionStreamRequestMessages = Annotated[
|
|
35
|
+
AgentsCompletionStreamRequestMessages = 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
|
+
]
|
|
28
44
|
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
AgentsCompletionStreamRequestToolChoiceTypedDict = Union[
|
|
47
|
+
ToolChoiceTypedDict, ToolChoiceEnum
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
AgentsCompletionStreamRequestToolChoice = Union[ToolChoice, ToolChoiceEnum]
|
|
52
|
+
|
|
31
53
|
|
|
32
54
|
class AgentsCompletionStreamRequestTypedDict(TypedDict):
|
|
33
55
|
messages: List[AgentsCompletionStreamRequestMessagesTypedDict]
|
|
@@ -36,8 +58,6 @@ class AgentsCompletionStreamRequestTypedDict(TypedDict):
|
|
|
36
58
|
r"""The ID of the agent to use for this completion."""
|
|
37
59
|
max_tokens: NotRequired[Nullable[int]]
|
|
38
60
|
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."""
|
|
39
|
-
min_tokens: NotRequired[Nullable[int]]
|
|
40
|
-
r"""The minimum number of tokens to generate in the completion."""
|
|
41
61
|
stream: NotRequired[bool]
|
|
42
62
|
stop: NotRequired[AgentsCompletionStreamRequestStopTypedDict]
|
|
43
63
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
@@ -45,31 +65,63 @@ class AgentsCompletionStreamRequestTypedDict(TypedDict):
|
|
|
45
65
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
46
66
|
response_format: NotRequired[ResponseFormatTypedDict]
|
|
47
67
|
tools: NotRequired[Nullable[List[ToolTypedDict]]]
|
|
48
|
-
tool_choice: NotRequired[
|
|
49
|
-
|
|
68
|
+
tool_choice: NotRequired[AgentsCompletionStreamRequestToolChoiceTypedDict]
|
|
69
|
+
presence_penalty: NotRequired[float]
|
|
70
|
+
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."""
|
|
71
|
+
frequency_penalty: NotRequired[float]
|
|
72
|
+
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."""
|
|
73
|
+
n: NotRequired[Nullable[int]]
|
|
74
|
+
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
75
|
+
|
|
50
76
|
|
|
51
77
|
class AgentsCompletionStreamRequest(BaseModel):
|
|
52
78
|
messages: List[AgentsCompletionStreamRequestMessages]
|
|
53
79
|
r"""The prompt(s) to generate completions for, encoded as a list of dict with role and content."""
|
|
80
|
+
|
|
54
81
|
agent_id: str
|
|
55
82
|
r"""The ID of the agent to use for this completion."""
|
|
83
|
+
|
|
56
84
|
max_tokens: OptionalNullable[int] = UNSET
|
|
57
85
|
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."""
|
|
58
|
-
|
|
59
|
-
r"""The minimum number of tokens to generate in the completion."""
|
|
86
|
+
|
|
60
87
|
stream: Optional[bool] = True
|
|
88
|
+
|
|
61
89
|
stop: Optional[AgentsCompletionStreamRequestStop] = None
|
|
62
90
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
91
|
+
|
|
63
92
|
random_seed: OptionalNullable[int] = UNSET
|
|
64
93
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
94
|
+
|
|
65
95
|
response_format: Optional[ResponseFormat] = None
|
|
96
|
+
|
|
66
97
|
tools: OptionalNullable[List[Tool]] = UNSET
|
|
67
|
-
|
|
68
|
-
|
|
98
|
+
|
|
99
|
+
tool_choice: Optional[AgentsCompletionStreamRequestToolChoice] = None
|
|
100
|
+
|
|
101
|
+
presence_penalty: Optional[float] = 0
|
|
102
|
+
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."""
|
|
103
|
+
|
|
104
|
+
frequency_penalty: Optional[float] = 0
|
|
105
|
+
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."""
|
|
106
|
+
|
|
107
|
+
n: OptionalNullable[int] = UNSET
|
|
108
|
+
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
109
|
+
|
|
69
110
|
@model_serializer(mode="wrap")
|
|
70
111
|
def serialize_model(self, handler):
|
|
71
|
-
optional_fields = [
|
|
72
|
-
|
|
112
|
+
optional_fields = [
|
|
113
|
+
"max_tokens",
|
|
114
|
+
"stream",
|
|
115
|
+
"stop",
|
|
116
|
+
"random_seed",
|
|
117
|
+
"response_format",
|
|
118
|
+
"tools",
|
|
119
|
+
"tool_choice",
|
|
120
|
+
"presence_penalty",
|
|
121
|
+
"frequency_penalty",
|
|
122
|
+
"n",
|
|
123
|
+
]
|
|
124
|
+
nullable_fields = ["max_tokens", "random_seed", "tools", "n"]
|
|
73
125
|
null_default_fields = []
|
|
74
126
|
|
|
75
127
|
serialized = handler(self)
|
|
@@ -79,9 +131,13 @@ class AgentsCompletionStreamRequest(BaseModel):
|
|
|
79
131
|
for n, f in self.model_fields.items():
|
|
80
132
|
k = f.alias or n
|
|
81
133
|
val = serialized.get(k)
|
|
134
|
+
serialized.pop(k, None)
|
|
82
135
|
|
|
83
136
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
84
|
-
is_set = (
|
|
137
|
+
is_set = (
|
|
138
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
139
|
+
or k in null_default_fields
|
|
140
|
+
) # pylint: disable=no-member
|
|
85
141
|
|
|
86
142
|
if val is not None and val != UNSET_SENTINEL:
|
|
87
143
|
m[k] = val
|
|
@@ -91,4 +147,3 @@ class AgentsCompletionStreamRequest(BaseModel):
|
|
|
91
147
|
m[k] = val
|
|
92
148
|
|
|
93
149
|
return m
|
|
94
|
-
|
|
@@ -2,20 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai.types import BaseModel
|
|
5
|
+
from mistralai.utils import validate_const
|
|
5
6
|
import pydantic
|
|
6
|
-
from
|
|
7
|
-
from
|
|
7
|
+
from pydantic.functional_validators import AfterValidator
|
|
8
|
+
from typing import Literal, Optional
|
|
9
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
ArchiveFTModelOutObject = Literal["model"]
|
|
11
13
|
|
|
14
|
+
|
|
12
15
|
class ArchiveFTModelOutTypedDict(TypedDict):
|
|
13
16
|
id: str
|
|
17
|
+
object: ArchiveFTModelOutObject
|
|
14
18
|
archived: NotRequired[bool]
|
|
15
|
-
|
|
19
|
+
|
|
16
20
|
|
|
17
21
|
class ArchiveFTModelOut(BaseModel):
|
|
18
22
|
id: str
|
|
19
|
-
|
|
23
|
+
|
|
24
|
+
OBJECT: Annotated[
|
|
25
|
+
Annotated[
|
|
26
|
+
Optional[ArchiveFTModelOutObject], AfterValidator(validate_const("model"))
|
|
27
|
+
],
|
|
28
|
+
pydantic.Field(alias="object"),
|
|
29
|
+
] = "model"
|
|
30
|
+
|
|
20
31
|
archived: Optional[bool] = True
|
|
21
|
-
|
|
@@ -1,30 +1,39 @@
|
|
|
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, Literal, Optional,
|
|
8
|
-
from typing_extensions import NotRequired
|
|
8
|
+
from typing import List, Literal, Optional, Union
|
|
9
|
+
from typing_extensions import NotRequired, TypedDict
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
AssistantMessageContentTypedDict = Union[str, List[ContentChunkTypedDict]]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
AssistantMessageContent = Union[str, List[ContentChunk]]
|
|
9
16
|
|
|
10
17
|
|
|
11
18
|
AssistantMessageRole = Literal["assistant"]
|
|
12
19
|
|
|
20
|
+
|
|
13
21
|
class AssistantMessageTypedDict(TypedDict):
|
|
14
|
-
content: NotRequired[Nullable[
|
|
22
|
+
content: NotRequired[Nullable[AssistantMessageContentTypedDict]]
|
|
15
23
|
tool_calls: NotRequired[Nullable[List[ToolCallTypedDict]]]
|
|
16
24
|
prefix: NotRequired[bool]
|
|
17
|
-
r"""Set this to `true` when adding an assistant message as prefix to condition the model response. The role of the prefix message is to force the model to start its answer by the content of the message."""
|
|
18
25
|
role: NotRequired[AssistantMessageRole]
|
|
19
|
-
|
|
26
|
+
|
|
20
27
|
|
|
21
28
|
class AssistantMessage(BaseModel):
|
|
22
|
-
content: OptionalNullable[
|
|
29
|
+
content: OptionalNullable[AssistantMessageContent] = UNSET
|
|
30
|
+
|
|
23
31
|
tool_calls: OptionalNullable[List[ToolCall]] = UNSET
|
|
32
|
+
|
|
24
33
|
prefix: Optional[bool] = False
|
|
25
|
-
|
|
34
|
+
|
|
26
35
|
role: Optional[AssistantMessageRole] = "assistant"
|
|
27
|
-
|
|
36
|
+
|
|
28
37
|
@model_serializer(mode="wrap")
|
|
29
38
|
def serialize_model(self, handler):
|
|
30
39
|
optional_fields = ["content", "tool_calls", "prefix", "role"]
|
|
@@ -38,9 +47,13 @@ class AssistantMessage(BaseModel):
|
|
|
38
47
|
for n, f in self.model_fields.items():
|
|
39
48
|
k = f.alias or n
|
|
40
49
|
val = serialized.get(k)
|
|
50
|
+
serialized.pop(k, None)
|
|
41
51
|
|
|
42
52
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
43
|
-
is_set = (
|
|
53
|
+
is_set = (
|
|
54
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
55
|
+
or k in null_default_fields
|
|
56
|
+
) # pylint: disable=no-member
|
|
44
57
|
|
|
45
58
|
if val is not None and val != UNSET_SENTINEL:
|
|
46
59
|
m[k] = val
|
|
@@ -50,4 +63,3 @@ class AssistantMessage(BaseModel):
|
|
|
50
63
|
m[k] = val
|
|
51
64
|
|
|
52
65
|
return m
|
|
53
|
-
|
|
@@ -4,44 +4,80 @@ from __future__ import annotations
|
|
|
4
4
|
from .modelcapabilities import ModelCapabilities, ModelCapabilitiesTypedDict
|
|
5
5
|
from datetime import datetime
|
|
6
6
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
7
|
+
from mistralai.utils import validate_const
|
|
8
|
+
import pydantic
|
|
7
9
|
from pydantic import model_serializer
|
|
8
|
-
from
|
|
9
|
-
from
|
|
10
|
+
from pydantic.functional_validators import AfterValidator
|
|
11
|
+
from typing import List, Literal, Optional
|
|
12
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
10
13
|
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
Type = Literal["base"]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class BaseModelCardTypedDict(TypedDict):
|
|
13
19
|
id: str
|
|
14
20
|
capabilities: ModelCapabilitiesTypedDict
|
|
15
21
|
object: NotRequired[str]
|
|
16
22
|
created: NotRequired[int]
|
|
17
23
|
owned_by: NotRequired[str]
|
|
18
|
-
root: NotRequired[Nullable[str]]
|
|
19
|
-
archived: NotRequired[bool]
|
|
20
24
|
name: NotRequired[Nullable[str]]
|
|
21
25
|
description: NotRequired[Nullable[str]]
|
|
22
26
|
max_context_length: NotRequired[int]
|
|
23
27
|
aliases: NotRequired[List[str]]
|
|
24
28
|
deprecation: NotRequired[Nullable[datetime]]
|
|
25
|
-
|
|
29
|
+
default_model_temperature: NotRequired[Nullable[float]]
|
|
30
|
+
type: Type
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
|
|
33
|
+
class BaseModelCard(BaseModel):
|
|
28
34
|
id: str
|
|
35
|
+
|
|
29
36
|
capabilities: ModelCapabilities
|
|
37
|
+
|
|
30
38
|
object: Optional[str] = "model"
|
|
39
|
+
|
|
31
40
|
created: Optional[int] = None
|
|
41
|
+
|
|
32
42
|
owned_by: Optional[str] = "mistralai"
|
|
33
|
-
|
|
34
|
-
archived: Optional[bool] = False
|
|
43
|
+
|
|
35
44
|
name: OptionalNullable[str] = UNSET
|
|
45
|
+
|
|
36
46
|
description: OptionalNullable[str] = UNSET
|
|
47
|
+
|
|
37
48
|
max_context_length: Optional[int] = 32768
|
|
49
|
+
|
|
38
50
|
aliases: Optional[List[str]] = None
|
|
51
|
+
|
|
39
52
|
deprecation: OptionalNullable[datetime] = UNSET
|
|
40
|
-
|
|
53
|
+
|
|
54
|
+
default_model_temperature: OptionalNullable[float] = UNSET
|
|
55
|
+
|
|
56
|
+
TYPE: Annotated[
|
|
57
|
+
Annotated[Optional[Type], AfterValidator(validate_const("base"))],
|
|
58
|
+
pydantic.Field(alias="type"),
|
|
59
|
+
] = "base"
|
|
60
|
+
|
|
41
61
|
@model_serializer(mode="wrap")
|
|
42
62
|
def serialize_model(self, handler):
|
|
43
|
-
optional_fields = [
|
|
44
|
-
|
|
63
|
+
optional_fields = [
|
|
64
|
+
"object",
|
|
65
|
+
"created",
|
|
66
|
+
"owned_by",
|
|
67
|
+
"name",
|
|
68
|
+
"description",
|
|
69
|
+
"max_context_length",
|
|
70
|
+
"aliases",
|
|
71
|
+
"deprecation",
|
|
72
|
+
"default_model_temperature",
|
|
73
|
+
"type",
|
|
74
|
+
]
|
|
75
|
+
nullable_fields = [
|
|
76
|
+
"name",
|
|
77
|
+
"description",
|
|
78
|
+
"deprecation",
|
|
79
|
+
"default_model_temperature",
|
|
80
|
+
]
|
|
45
81
|
null_default_fields = []
|
|
46
82
|
|
|
47
83
|
serialized = handler(self)
|
|
@@ -51,9 +87,13 @@ class ModelCard(BaseModel):
|
|
|
51
87
|
for n, f in self.model_fields.items():
|
|
52
88
|
k = f.alias or n
|
|
53
89
|
val = serialized.get(k)
|
|
90
|
+
serialized.pop(k, None)
|
|
54
91
|
|
|
55
92
|
optional_nullable = k in optional_fields and k in nullable_fields
|
|
56
|
-
is_set = (
|
|
93
|
+
is_set = (
|
|
94
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
95
|
+
or k in null_default_fields
|
|
96
|
+
) # pylint: disable=no-member
|
|
57
97
|
|
|
58
98
|
if val is not None and val != UNSET_SENTINEL:
|
|
59
99
|
m[k] = val
|
|
@@ -63,4 +103,3 @@ class ModelCard(BaseModel):
|
|
|
63
103
|
m[k] = val
|
|
64
104
|
|
|
65
105
|
return m
|
|
66
|
-
|
|
@@ -0,0 +1,17 @@
|
|
|
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 Optional
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BatchErrorTypedDict(TypedDict):
|
|
10
|
+
message: str
|
|
11
|
+
count: NotRequired[int]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BatchError(BaseModel):
|
|
15
|
+
message: str
|
|
16
|
+
|
|
17
|
+
count: Optional[int] = 1
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .apiendpoint import APIEndpoint
|
|
5
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
6
|
+
from pydantic import model_serializer
|
|
7
|
+
from typing import Dict, List, Optional
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BatchJobInTypedDict(TypedDict):
|
|
12
|
+
input_files: List[str]
|
|
13
|
+
endpoint: APIEndpoint
|
|
14
|
+
model: str
|
|
15
|
+
metadata: NotRequired[Nullable[Dict[str, str]]]
|
|
16
|
+
timeout_hours: NotRequired[int]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BatchJobIn(BaseModel):
|
|
20
|
+
input_files: List[str]
|
|
21
|
+
|
|
22
|
+
endpoint: APIEndpoint
|
|
23
|
+
|
|
24
|
+
model: str
|
|
25
|
+
|
|
26
|
+
metadata: OptionalNullable[Dict[str, str]] = UNSET
|
|
27
|
+
|
|
28
|
+
timeout_hours: Optional[int] = 24
|
|
29
|
+
|
|
30
|
+
@model_serializer(mode="wrap")
|
|
31
|
+
def serialize_model(self, handler):
|
|
32
|
+
optional_fields = ["metadata", "timeout_hours"]
|
|
33
|
+
nullable_fields = ["metadata"]
|
|
34
|
+
null_default_fields = []
|
|
35
|
+
|
|
36
|
+
serialized = handler(self)
|
|
37
|
+
|
|
38
|
+
m = {}
|
|
39
|
+
|
|
40
|
+
for n, f in self.model_fields.items():
|
|
41
|
+
k = f.alias or n
|
|
42
|
+
val = serialized.get(k)
|
|
43
|
+
serialized.pop(k, None)
|
|
44
|
+
|
|
45
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
46
|
+
is_set = (
|
|
47
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
48
|
+
or k in null_default_fields
|
|
49
|
+
) # pylint: disable=no-member
|
|
50
|
+
|
|
51
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
52
|
+
m[k] = val
|
|
53
|
+
elif val != UNSET_SENTINEL and (
|
|
54
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
55
|
+
):
|
|
56
|
+
m[k] = val
|
|
57
|
+
|
|
58
|
+
return m
|