mistralai 1.1.0__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/_version.py +12 -0
- mistralai/agents.py +56 -22
- mistralai/batch.py +17 -0
- mistralai/chat.py +64 -30
- mistralai/classifiers.py +396 -0
- mistralai/embeddings.py +10 -6
- mistralai/files.py +252 -19
- mistralai/fim.py +40 -30
- mistralai/jobs.py +40 -20
- mistralai/mistral_jobs.py +733 -0
- mistralai/models/__init__.py +108 -18
- mistralai/models/agentscompletionrequest.py +27 -10
- mistralai/models/agentscompletionstreamrequest.py +27 -10
- mistralai/models/apiendpoint.py +9 -0
- mistralai/models/archiveftmodelout.py +11 -5
- mistralai/models/assistantmessage.py +11 -6
- mistralai/models/basemodelcard.py +22 -6
- 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 +9 -4
- mistralai/models/chatcompletionrequest.py +32 -13
- mistralai/models/chatcompletionresponse.py +2 -2
- mistralai/models/chatcompletionstreamrequest.py +32 -13
- mistralai/models/checkpointout.py +1 -1
- mistralai/models/classificationobject.py +21 -0
- mistralai/models/classificationrequest.py +59 -0
- mistralai/models/classificationresponse.py +21 -0
- mistralai/models/completionchunk.py +2 -2
- mistralai/models/completionevent.py +1 -1
- mistralai/models/completionresponsestreamchoice.py +11 -5
- mistralai/models/delete_model_v1_models_model_id_deleteop.py +1 -2
- mistralai/models/deletefileout.py +1 -1
- mistralai/models/deletemodelout.py +2 -2
- mistralai/models/deltamessage.py +14 -7
- mistralai/models/detailedjobout.py +11 -5
- mistralai/models/embeddingrequest.py +5 -5
- mistralai/models/embeddingresponse.py +2 -1
- mistralai/models/embeddingresponsedata.py +2 -2
- mistralai/models/eventout.py +2 -2
- mistralai/models/filepurpose.py +8 -0
- mistralai/models/files_api_routes_delete_fileop.py +1 -2
- 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 +1 -2
- mistralai/models/files_api_routes_upload_fileop.py +9 -9
- mistralai/models/fileschema.py +7 -21
- mistralai/models/fimcompletionrequest.py +20 -13
- mistralai/models/fimcompletionresponse.py +2 -2
- mistralai/models/fimcompletionstreamrequest.py +20 -13
- mistralai/models/ftmodelcapabilitiesout.py +2 -2
- mistralai/models/ftmodelcard.py +24 -6
- mistralai/models/ftmodelout.py +9 -5
- mistralai/models/function.py +2 -2
- mistralai/models/functioncall.py +2 -1
- mistralai/models/functionname.py +1 -1
- mistralai/models/githubrepositoryin.py +11 -5
- mistralai/models/githubrepositoryout.py +11 -5
- mistralai/models/httpvalidationerror.py +0 -2
- mistralai/models/imageurl.py +1 -2
- mistralai/models/imageurlchunk.py +11 -5
- mistralai/models/jobin.py +2 -2
- mistralai/models/jobmetadataout.py +1 -2
- mistralai/models/jobout.py +10 -5
- 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 +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +2 -2
- mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +1 -2
- mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +1 -2
- mistralai/models/jobsout.py +9 -5
- mistralai/models/legacyjobmetadataout.py +12 -5
- mistralai/models/listfilesout.py +5 -1
- mistralai/models/metricout.py +1 -2
- mistralai/models/modelcapabilities.py +2 -2
- mistralai/models/modellist.py +2 -2
- mistralai/models/responseformat.py +2 -2
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -2
- mistralai/models/retrievefileout.py +10 -21
- mistralai/models/sampletype.py +6 -2
- mistralai/models/security.py +2 -2
- mistralai/models/source.py +3 -2
- mistralai/models/systemmessage.py +6 -6
- mistralai/models/textchunk.py +9 -5
- mistralai/models/tool.py +2 -2
- mistralai/models/toolcall.py +2 -2
- mistralai/models/toolchoice.py +2 -2
- mistralai/models/toolmessage.py +2 -2
- mistralai/models/trainingfile.py +2 -2
- mistralai/models/trainingparameters.py +7 -2
- mistralai/models/trainingparametersin.py +7 -2
- mistralai/models/unarchiveftmodelout.py +11 -5
- mistralai/models/updateftmodelin.py +1 -2
- mistralai/models/uploadfileout.py +7 -21
- mistralai/models/usageinfo.py +1 -1
- mistralai/models/usermessage.py +36 -5
- mistralai/models/validationerror.py +2 -1
- mistralai/models/wandbintegration.py +11 -5
- mistralai/models/wandbintegrationout.py +12 -6
- mistralai/models_.py +48 -24
- mistralai/sdk.py +7 -0
- mistralai/sdkconfiguration.py +7 -7
- mistralai/utils/__init__.py +8 -0
- mistralai/utils/annotations.py +13 -2
- mistralai/utils/serializers.py +25 -0
- {mistralai-1.1.0.dist-info → mistralai-1.2.0.dist-info}/METADATA +90 -14
- mistralai-1.2.0.dist-info/RECORD +276 -0
- {mistralai-1.1.0.dist-info → mistralai-1.2.0.dist-info}/WHEEL +1 -1
- mistralai_azure/__init__.py +4 -0
- mistralai_azure/_version.py +12 -0
- mistralai_azure/chat.py +64 -30
- mistralai_azure/models/__init__.py +9 -3
- mistralai_azure/models/assistantmessage.py +11 -6
- mistralai_azure/models/chatcompletionchoice.py +10 -5
- mistralai_azure/models/chatcompletionrequest.py +32 -13
- mistralai_azure/models/chatcompletionresponse.py +2 -2
- mistralai_azure/models/chatcompletionstreamrequest.py +32 -13
- mistralai_azure/models/completionchunk.py +2 -2
- mistralai_azure/models/completionevent.py +1 -1
- mistralai_azure/models/completionresponsestreamchoice.py +9 -4
- mistralai_azure/models/deltamessage.py +14 -7
- mistralai_azure/models/function.py +2 -2
- mistralai_azure/models/functioncall.py +2 -1
- mistralai_azure/models/functionname.py +1 -1
- mistralai_azure/models/httpvalidationerror.py +0 -2
- mistralai_azure/models/responseformat.py +2 -2
- mistralai_azure/models/security.py +1 -2
- mistralai_azure/models/systemmessage.py +6 -6
- mistralai_azure/models/textchunk.py +9 -5
- mistralai_azure/models/tool.py +2 -2
- mistralai_azure/models/toolcall.py +2 -2
- mistralai_azure/models/toolchoice.py +2 -2
- mistralai_azure/models/toolmessage.py +2 -2
- mistralai_azure/models/usageinfo.py +1 -1
- mistralai_azure/models/usermessage.py +36 -5
- mistralai_azure/models/validationerror.py +2 -1
- mistralai_azure/sdkconfiguration.py +7 -7
- mistralai_azure/utils/__init__.py +8 -0
- mistralai_azure/utils/annotations.py +13 -2
- mistralai_azure/utils/serializers.py +25 -0
- mistralai_gcp/__init__.py +4 -0
- mistralai_gcp/_version.py +12 -0
- mistralai_gcp/chat.py +64 -30
- mistralai_gcp/fim.py +40 -30
- mistralai_gcp/models/__init__.py +9 -3
- mistralai_gcp/models/assistantmessage.py +11 -6
- mistralai_gcp/models/chatcompletionchoice.py +10 -5
- mistralai_gcp/models/chatcompletionrequest.py +32 -13
- mistralai_gcp/models/chatcompletionresponse.py +2 -2
- mistralai_gcp/models/chatcompletionstreamrequest.py +32 -13
- mistralai_gcp/models/completionchunk.py +2 -2
- mistralai_gcp/models/completionevent.py +1 -1
- mistralai_gcp/models/completionresponsestreamchoice.py +9 -4
- mistralai_gcp/models/deltamessage.py +14 -7
- mistralai_gcp/models/fimcompletionrequest.py +20 -13
- mistralai_gcp/models/fimcompletionresponse.py +2 -2
- mistralai_gcp/models/fimcompletionstreamrequest.py +20 -13
- mistralai_gcp/models/function.py +2 -2
- mistralai_gcp/models/functioncall.py +2 -1
- mistralai_gcp/models/functionname.py +1 -1
- mistralai_gcp/models/httpvalidationerror.py +0 -2
- mistralai_gcp/models/responseformat.py +2 -2
- mistralai_gcp/models/security.py +1 -2
- mistralai_gcp/models/systemmessage.py +6 -6
- mistralai_gcp/models/textchunk.py +9 -5
- mistralai_gcp/models/tool.py +2 -2
- mistralai_gcp/models/toolcall.py +2 -2
- mistralai_gcp/models/toolchoice.py +2 -2
- mistralai_gcp/models/toolmessage.py +2 -2
- mistralai_gcp/models/usageinfo.py +1 -1
- mistralai_gcp/models/usermessage.py +36 -5
- mistralai_gcp/models/validationerror.py +2 -1
- mistralai_gcp/sdkconfiguration.py +7 -7
- mistralai_gcp/utils/__init__.py +8 -0
- mistralai_gcp/utils/annotations.py +13 -2
- mistralai_gcp/utils/serializers.py +25 -0
- mistralai-1.1.0.dist-info/RECORD +0 -254
- {mistralai-1.1.0.dist-info → mistralai-1.2.0.dist-info}/LICENSE +0 -0
|
@@ -18,8 +18,8 @@ from mistralai_azure.types import (
|
|
|
18
18
|
)
|
|
19
19
|
from mistralai_azure.utils import get_discriminator
|
|
20
20
|
from pydantic import Discriminator, Tag, model_serializer
|
|
21
|
-
from typing import List, Optional,
|
|
22
|
-
from typing_extensions import Annotated, NotRequired
|
|
21
|
+
from typing import List, Optional, Union
|
|
22
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
StopTypedDict = Union[str, List[str]]
|
|
@@ -62,14 +62,12 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
|
|
|
62
62
|
r"""The prompt(s) to generate completions for, encoded as a list of dict with role and content."""
|
|
63
63
|
model: NotRequired[Nullable[str]]
|
|
64
64
|
r"""The ID of the model to use for this request."""
|
|
65
|
-
temperature: NotRequired[float]
|
|
66
|
-
r"""What sampling temperature to use, between 0.0 and
|
|
65
|
+
temperature: NotRequired[Nullable[float]]
|
|
66
|
+
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."""
|
|
67
67
|
top_p: NotRequired[float]
|
|
68
68
|
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."""
|
|
69
69
|
max_tokens: NotRequired[Nullable[int]]
|
|
70
70
|
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."""
|
|
71
|
-
min_tokens: NotRequired[Nullable[int]]
|
|
72
|
-
r"""The minimum number of tokens to generate in the completion."""
|
|
73
71
|
stream: NotRequired[bool]
|
|
74
72
|
stop: NotRequired[StopTypedDict]
|
|
75
73
|
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
|
|
@@ -78,6 +76,12 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
|
|
|
78
76
|
response_format: NotRequired[ResponseFormatTypedDict]
|
|
79
77
|
tools: NotRequired[Nullable[List[ToolTypedDict]]]
|
|
80
78
|
tool_choice: NotRequired[ChatCompletionStreamRequestToolChoiceTypedDict]
|
|
79
|
+
presence_penalty: NotRequired[float]
|
|
80
|
+
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."""
|
|
81
|
+
frequency_penalty: NotRequired[float]
|
|
82
|
+
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."""
|
|
83
|
+
n: NotRequired[Nullable[int]]
|
|
84
|
+
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
81
85
|
safe_prompt: NotRequired[bool]
|
|
82
86
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
83
87
|
|
|
@@ -89,8 +93,8 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
89
93
|
model: OptionalNullable[str] = "azureai"
|
|
90
94
|
r"""The ID of the model to use for this request."""
|
|
91
95
|
|
|
92
|
-
temperature:
|
|
93
|
-
r"""What sampling temperature to use, between 0.0 and
|
|
96
|
+
temperature: OptionalNullable[float] = UNSET
|
|
97
|
+
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."""
|
|
94
98
|
|
|
95
99
|
top_p: Optional[float] = 1
|
|
96
100
|
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."""
|
|
@@ -98,9 +102,6 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
98
102
|
max_tokens: OptionalNullable[int] = UNSET
|
|
99
103
|
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."""
|
|
100
104
|
|
|
101
|
-
min_tokens: OptionalNullable[int] = UNSET
|
|
102
|
-
r"""The minimum number of tokens to generate in the completion."""
|
|
103
|
-
|
|
104
105
|
stream: Optional[bool] = True
|
|
105
106
|
|
|
106
107
|
stop: Optional[Stop] = None
|
|
@@ -115,6 +116,15 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
115
116
|
|
|
116
117
|
tool_choice: Optional[ChatCompletionStreamRequestToolChoice] = None
|
|
117
118
|
|
|
119
|
+
presence_penalty: Optional[float] = 0
|
|
120
|
+
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."""
|
|
121
|
+
|
|
122
|
+
frequency_penalty: Optional[float] = 0
|
|
123
|
+
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."""
|
|
124
|
+
|
|
125
|
+
n: OptionalNullable[int] = UNSET
|
|
126
|
+
r"""Number of completions to return for each request, input tokens are only billed once."""
|
|
127
|
+
|
|
118
128
|
safe_prompt: Optional[bool] = False
|
|
119
129
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
120
130
|
|
|
@@ -125,16 +135,25 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
125
135
|
"temperature",
|
|
126
136
|
"top_p",
|
|
127
137
|
"max_tokens",
|
|
128
|
-
"min_tokens",
|
|
129
138
|
"stream",
|
|
130
139
|
"stop",
|
|
131
140
|
"random_seed",
|
|
132
141
|
"response_format",
|
|
133
142
|
"tools",
|
|
134
143
|
"tool_choice",
|
|
144
|
+
"presence_penalty",
|
|
145
|
+
"frequency_penalty",
|
|
146
|
+
"n",
|
|
135
147
|
"safe_prompt",
|
|
136
148
|
]
|
|
137
|
-
nullable_fields = [
|
|
149
|
+
nullable_fields = [
|
|
150
|
+
"model",
|
|
151
|
+
"temperature",
|
|
152
|
+
"max_tokens",
|
|
153
|
+
"random_seed",
|
|
154
|
+
"tools",
|
|
155
|
+
"n",
|
|
156
|
+
]
|
|
138
157
|
null_default_fields = []
|
|
139
158
|
|
|
140
159
|
serialized = handler(self)
|
|
@@ -7,8 +7,8 @@ from .completionresponsestreamchoice import (
|
|
|
7
7
|
)
|
|
8
8
|
from .usageinfo import UsageInfo, UsageInfoTypedDict
|
|
9
9
|
from mistralai_azure.types import BaseModel
|
|
10
|
-
from typing import List, Optional
|
|
11
|
-
from typing_extensions import NotRequired
|
|
10
|
+
from typing import List, Optional
|
|
11
|
+
from typing_extensions import NotRequired, TypedDict
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class CompletionChunkTypedDict(TypedDict):
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .completionchunk import CompletionChunk, CompletionChunkTypedDict
|
|
5
5
|
from mistralai_azure.types import BaseModel
|
|
6
|
-
from
|
|
6
|
+
from typing_extensions import TypedDict
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class CompletionEventTypedDict(TypedDict):
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .deltamessage import DeltaMessage, DeltaMessageTypedDict
|
|
5
|
-
from mistralai_azure.types import BaseModel, Nullable, UNSET_SENTINEL
|
|
5
|
+
from mistralai_azure.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
|
|
6
|
+
from mistralai_azure.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
|
-
FinishReason = Literal["stop", "length", "error", "tool_calls"]
|
|
13
|
+
FinishReason = Union[Literal["stop", "length", "error", "tool_calls"], UnrecognizedStr]
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
class CompletionResponseStreamChoiceTypedDict(TypedDict):
|
|
@@ -21,7 +24,9 @@ class CompletionResponseStreamChoice(BaseModel):
|
|
|
21
24
|
|
|
22
25
|
delta: DeltaMessage
|
|
23
26
|
|
|
24
|
-
finish_reason:
|
|
27
|
+
finish_reason: Annotated[
|
|
28
|
+
Nullable[FinishReason], PlainValidator(validate_open_enum(False))
|
|
29
|
+
]
|
|
25
30
|
|
|
26
31
|
@model_serializer(mode="wrap")
|
|
27
32
|
def serialize_model(self, handler):
|
|
@@ -1,6 +1,7 @@
|
|
|
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_azure.types import (
|
|
6
7
|
BaseModel,
|
|
@@ -10,27 +11,33 @@ from mistralai_azure.types import (
|
|
|
10
11
|
UNSET_SENTINEL,
|
|
11
12
|
)
|
|
12
13
|
from pydantic import model_serializer
|
|
13
|
-
from typing import List,
|
|
14
|
-
from typing_extensions import NotRequired
|
|
14
|
+
from typing import List, Union
|
|
15
|
+
from typing_extensions import NotRequired, TypedDict
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
ContentTypedDict = Union[str, List[ContentChunkTypedDict]]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Content = Union[str, List[ContentChunk]]
|
|
15
22
|
|
|
16
23
|
|
|
17
24
|
class DeltaMessageTypedDict(TypedDict):
|
|
18
|
-
role: NotRequired[str]
|
|
19
|
-
content: NotRequired[Nullable[
|
|
25
|
+
role: NotRequired[Nullable[str]]
|
|
26
|
+
content: NotRequired[Nullable[ContentTypedDict]]
|
|
20
27
|
tool_calls: NotRequired[Nullable[List[ToolCallTypedDict]]]
|
|
21
28
|
|
|
22
29
|
|
|
23
30
|
class DeltaMessage(BaseModel):
|
|
24
|
-
role:
|
|
31
|
+
role: OptionalNullable[str] = UNSET
|
|
25
32
|
|
|
26
|
-
content: OptionalNullable[
|
|
33
|
+
content: OptionalNullable[Content] = UNSET
|
|
27
34
|
|
|
28
35
|
tool_calls: OptionalNullable[List[ToolCall]] = UNSET
|
|
29
36
|
|
|
30
37
|
@model_serializer(mode="wrap")
|
|
31
38
|
def serialize_model(self, handler):
|
|
32
39
|
optional_fields = ["role", "content", "tool_calls"]
|
|
33
|
-
nullable_fields = ["content", "tool_calls"]
|
|
40
|
+
nullable_fields = ["role", "content", "tool_calls"]
|
|
34
41
|
null_default_fields = []
|
|
35
42
|
|
|
36
43
|
serialized = handler(self)
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai_azure.types import BaseModel
|
|
5
|
-
from typing import Any, Dict, Optional
|
|
6
|
-
from typing_extensions import NotRequired
|
|
5
|
+
from typing import Any, Dict, Optional
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class FunctionTypedDict(TypedDict):
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai_azure.types import BaseModel
|
|
5
|
-
from typing import Any, Dict,
|
|
5
|
+
from typing import Any, Dict, Union
|
|
6
|
+
from typing_extensions import TypedDict
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
ArgumentsTypedDict = Union[Dict[str, Any], str]
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .responseformats import ResponseFormats
|
|
5
5
|
from mistralai_azure.types import BaseModel
|
|
6
|
-
from typing import Optional
|
|
7
|
-
from typing_extensions import NotRequired
|
|
6
|
+
from typing import Optional
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class ResponseFormatTypedDict(TypedDict):
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai_azure.types import BaseModel
|
|
5
5
|
from mistralai_azure.utils import FieldMetadata, SecurityMetadata
|
|
6
|
-
from
|
|
7
|
-
from typing_extensions import Annotated
|
|
6
|
+
from typing_extensions import Annotated, TypedDict
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class SecurityTypedDict(TypedDict):
|
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .textchunk import TextChunk, TextChunkTypedDict
|
|
5
5
|
from mistralai_azure.types import BaseModel
|
|
6
|
-
from typing import List, Literal, Optional,
|
|
7
|
-
from typing_extensions import NotRequired
|
|
6
|
+
from typing import List, Literal, Optional, Union
|
|
7
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
SystemMessageContentTypedDict = Union[str, List[TextChunkTypedDict]]
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
SystemMessageContent = Union[str, List[TextChunk]]
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
Role = Literal["system"]
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class SystemMessageTypedDict(TypedDict):
|
|
20
|
-
content:
|
|
20
|
+
content: SystemMessageContentTypedDict
|
|
21
21
|
role: NotRequired[Role]
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class SystemMessage(BaseModel):
|
|
25
|
-
content:
|
|
25
|
+
content: SystemMessageContent
|
|
26
26
|
|
|
27
27
|
role: Optional[Role] = "system"
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai_azure.types import BaseModel
|
|
5
|
+
from mistralai_azure.utils import validate_const
|
|
5
6
|
import pydantic
|
|
6
|
-
from
|
|
7
|
-
from
|
|
7
|
+
from pydantic.functional_validators import AfterValidator
|
|
8
|
+
from typing import Literal, Optional
|
|
9
|
+
from typing_extensions import Annotated, TypedDict
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
Type = Literal["text"]
|
|
@@ -12,11 +14,13 @@ Type = Literal["text"]
|
|
|
12
14
|
|
|
13
15
|
class TextChunkTypedDict(TypedDict):
|
|
14
16
|
text: str
|
|
17
|
+
type: Type
|
|
15
18
|
|
|
16
19
|
|
|
17
20
|
class TextChunk(BaseModel):
|
|
18
21
|
text: str
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
TYPE: Annotated[
|
|
24
|
+
Annotated[Optional[Type], AfterValidator(validate_const("text"))],
|
|
25
|
+
pydantic.Field(alias="type"),
|
|
26
|
+
] = "text"
|
mistralai_azure/models/tool.py
CHANGED
|
@@ -6,8 +6,8 @@ from .tooltypes import ToolTypes
|
|
|
6
6
|
from mistralai_azure.types import BaseModel
|
|
7
7
|
from mistralai_azure.utils import validate_open_enum
|
|
8
8
|
from pydantic.functional_validators import PlainValidator
|
|
9
|
-
from typing import Optional
|
|
10
|
-
from typing_extensions import Annotated, NotRequired
|
|
9
|
+
from typing import Optional
|
|
10
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class ToolTypedDict(TypedDict):
|
|
@@ -6,8 +6,8 @@ from .tooltypes import ToolTypes
|
|
|
6
6
|
from mistralai_azure.types import BaseModel
|
|
7
7
|
from mistralai_azure.utils import validate_open_enum
|
|
8
8
|
from pydantic.functional_validators import PlainValidator
|
|
9
|
-
from typing import Optional
|
|
10
|
-
from typing_extensions import Annotated, NotRequired
|
|
9
|
+
from typing import Optional
|
|
10
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class ToolCallTypedDict(TypedDict):
|
|
@@ -6,8 +6,8 @@ from .tooltypes import ToolTypes
|
|
|
6
6
|
from mistralai_azure.types import BaseModel
|
|
7
7
|
from mistralai_azure.utils import validate_open_enum
|
|
8
8
|
from pydantic.functional_validators import PlainValidator
|
|
9
|
-
from typing import Optional
|
|
10
|
-
from typing_extensions import Annotated, NotRequired
|
|
9
|
+
from typing import Optional
|
|
10
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class ToolChoiceTypedDict(TypedDict):
|
|
@@ -9,8 +9,8 @@ from mistralai_azure.types import (
|
|
|
9
9
|
UNSET_SENTINEL,
|
|
10
10
|
)
|
|
11
11
|
from pydantic import model_serializer
|
|
12
|
-
from typing import Literal, Optional
|
|
13
|
-
from typing_extensions import NotRequired
|
|
12
|
+
from typing import Literal, Optional
|
|
13
|
+
from typing_extensions import NotRequired, TypedDict
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
ToolMessageRole = Literal["tool"]
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .contentchunk import ContentChunk, ContentChunkTypedDict
|
|
5
|
-
from mistralai_azure.types import BaseModel
|
|
6
|
-
from
|
|
7
|
-
from
|
|
5
|
+
from mistralai_azure.types import BaseModel, Nullable, UNSET_SENTINEL
|
|
6
|
+
from pydantic import model_serializer
|
|
7
|
+
from typing import List, Literal, Optional, Union
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
UserMessageContentTypedDict = Union[str, List[ContentChunkTypedDict]]
|
|
@@ -17,11 +18,41 @@ UserMessageRole = Literal["user"]
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
class UserMessageTypedDict(TypedDict):
|
|
20
|
-
content: UserMessageContentTypedDict
|
|
21
|
+
content: Nullable[UserMessageContentTypedDict]
|
|
21
22
|
role: NotRequired[UserMessageRole]
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
class UserMessage(BaseModel):
|
|
25
|
-
content: UserMessageContent
|
|
26
|
+
content: Nullable[UserMessageContent]
|
|
26
27
|
|
|
27
28
|
role: Optional[UserMessageRole] = "user"
|
|
29
|
+
|
|
30
|
+
@model_serializer(mode="wrap")
|
|
31
|
+
def serialize_model(self, handler):
|
|
32
|
+
optional_fields = ["role"]
|
|
33
|
+
nullable_fields = ["content"]
|
|
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
|
|
@@ -10,10 +10,10 @@ from pydantic import Field
|
|
|
10
10
|
from typing import Callable, Dict, Optional, Tuple, Union
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
r"""Production server"""
|
|
13
|
+
SERVER_EU = "eu"
|
|
14
|
+
r"""EU Production server"""
|
|
15
15
|
SERVERS = {
|
|
16
|
-
|
|
16
|
+
SERVER_EU: "https://api.mistral.ai",
|
|
17
17
|
}
|
|
18
18
|
"""Contains the list of servers available to the SDK"""
|
|
19
19
|
|
|
@@ -28,9 +28,9 @@ class SDKConfiguration:
|
|
|
28
28
|
server: Optional[str] = ""
|
|
29
29
|
language: str = "python"
|
|
30
30
|
openapi_doc_version: str = "0.0.2"
|
|
31
|
-
sdk_version: str = "1.2.
|
|
32
|
-
gen_version: str = "2.
|
|
33
|
-
user_agent: str = "speakeasy-sdk/python 1.2.
|
|
31
|
+
sdk_version: str = "1.2.0"
|
|
32
|
+
gen_version: str = "2.452.0"
|
|
33
|
+
user_agent: str = "speakeasy-sdk/python 1.2.0 2.452.0 0.0.2 mistralai_azure"
|
|
34
34
|
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
|
35
35
|
timeout_ms: Optional[int] = None
|
|
36
36
|
|
|
@@ -41,7 +41,7 @@ class SDKConfiguration:
|
|
|
41
41
|
if self.server_url is not None and self.server_url:
|
|
42
42
|
return remove_suffix(self.server_url, "/"), {}
|
|
43
43
|
if not self.server:
|
|
44
|
-
self.server =
|
|
44
|
+
self.server = SERVER_EU
|
|
45
45
|
|
|
46
46
|
if self.server not in SERVERS:
|
|
47
47
|
raise ValueError(f'Invalid server "{self.server}"')
|
|
@@ -27,6 +27,10 @@ from .serializers import (
|
|
|
27
27
|
serialize_float,
|
|
28
28
|
serialize_int,
|
|
29
29
|
stream_to_text,
|
|
30
|
+
stream_to_text_async,
|
|
31
|
+
stream_to_bytes,
|
|
32
|
+
stream_to_bytes_async,
|
|
33
|
+
validate_const,
|
|
30
34
|
validate_decimal,
|
|
31
35
|
validate_float,
|
|
32
36
|
validate_int,
|
|
@@ -79,10 +83,14 @@ __all__ = [
|
|
|
79
83
|
"serialize_request_body",
|
|
80
84
|
"SerializedRequestBody",
|
|
81
85
|
"stream_to_text",
|
|
86
|
+
"stream_to_text_async",
|
|
87
|
+
"stream_to_bytes",
|
|
88
|
+
"stream_to_bytes_async",
|
|
82
89
|
"template_url",
|
|
83
90
|
"unmarshal",
|
|
84
91
|
"unmarshal_json",
|
|
85
92
|
"validate_decimal",
|
|
93
|
+
"validate_const",
|
|
86
94
|
"validate_float",
|
|
87
95
|
"validate_int",
|
|
88
96
|
"validate_open_enum",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
+
from enum import Enum
|
|
3
4
|
from typing import Any
|
|
4
5
|
|
|
5
6
|
def get_discriminator(model: Any, fieldname: str, key: str) -> str:
|
|
@@ -10,10 +11,20 @@ def get_discriminator(model: Any, fieldname: str, key: str) -> str:
|
|
|
10
11
|
raise ValueError(f'Could not find discriminator key {key} in {model}') from e
|
|
11
12
|
|
|
12
13
|
if hasattr(model, fieldname):
|
|
13
|
-
|
|
14
|
+
attr = getattr(model, fieldname)
|
|
15
|
+
|
|
16
|
+
if isinstance(attr, Enum):
|
|
17
|
+
return f'{attr.value}'
|
|
18
|
+
|
|
19
|
+
return f'{attr}'
|
|
14
20
|
|
|
15
21
|
fieldname = fieldname.upper()
|
|
16
22
|
if hasattr(model, fieldname):
|
|
17
|
-
|
|
23
|
+
attr = getattr(model, fieldname)
|
|
24
|
+
|
|
25
|
+
if isinstance(attr, Enum):
|
|
26
|
+
return f'{attr.value}'
|
|
27
|
+
|
|
28
|
+
return f'{attr}'
|
|
18
29
|
|
|
19
30
|
raise ValueError(f'Could not find discriminator field {fieldname} in {model}')
|
|
@@ -116,6 +116,19 @@ def validate_open_enum(is_int: bool):
|
|
|
116
116
|
return validate
|
|
117
117
|
|
|
118
118
|
|
|
119
|
+
def validate_const(v):
|
|
120
|
+
def validate(c):
|
|
121
|
+
if is_optional_type(type(c)) and c is None:
|
|
122
|
+
return None
|
|
123
|
+
|
|
124
|
+
if v != c:
|
|
125
|
+
raise ValueError(f"Expected {v}")
|
|
126
|
+
|
|
127
|
+
return c
|
|
128
|
+
|
|
129
|
+
return validate
|
|
130
|
+
|
|
131
|
+
|
|
119
132
|
def unmarshal_json(raw, typ: Any) -> Any:
|
|
120
133
|
return unmarshal(from_json(raw), typ)
|
|
121
134
|
|
|
@@ -172,6 +185,18 @@ def stream_to_text(stream: httpx.Response) -> str:
|
|
|
172
185
|
return "".join(stream.iter_text())
|
|
173
186
|
|
|
174
187
|
|
|
188
|
+
async def stream_to_text_async(stream: httpx.Response) -> str:
|
|
189
|
+
return "".join([chunk async for chunk in stream.aiter_text()])
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def stream_to_bytes(stream: httpx.Response) -> bytes:
|
|
193
|
+
return stream.content
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
async def stream_to_bytes_async(stream: httpx.Response) -> bytes:
|
|
197
|
+
return await stream.aread()
|
|
198
|
+
|
|
199
|
+
|
|
175
200
|
def get_pydantic_model(data: Any, typ: Any) -> Any:
|
|
176
201
|
if not _contains_pydantic_model(data):
|
|
177
202
|
return unmarshal(data, typ)
|
mistralai_gcp/__init__.py
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
import importlib.metadata
|
|
4
|
+
|
|
5
|
+
__title__: str = "mistralai-gcp"
|
|
6
|
+
__version__: str = "1.2.0"
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
if __package__ is not None:
|
|
10
|
+
__version__ = importlib.metadata.version(__package__)
|
|
11
|
+
except importlib.metadata.PackageNotFoundError:
|
|
12
|
+
pass
|