mistralai 0.5.5a50__py3-none-any.whl → 1.0.0rc2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mistralai/agents.py +434 -0
- mistralai/basesdk.py +43 -6
- mistralai/chat.py +29 -34
- mistralai/embeddings.py +4 -4
- mistralai/files.py +10 -10
- mistralai/fim.py +17 -18
- mistralai/fine_tuning.py +10 -849
- mistralai/jobs.py +854 -0
- mistralai/models/__init__.py +4 -2
- mistralai/models/agentscompletionrequest.py +96 -0
- mistralai/models/agentscompletionstreamrequest.py +92 -0
- mistralai/models/assistantmessage.py +4 -9
- mistralai/models/chatcompletionchoice.py +4 -15
- mistralai/models/chatcompletionrequest.py +11 -16
- mistralai/models/chatcompletionstreamrequest.py +11 -16
- mistralai/models/completionresponsestreamchoice.py +4 -9
- mistralai/models/deltamessage.py +4 -9
- mistralai/models/detailedjobout.py +4 -9
- mistralai/models/embeddingrequest.py +4 -9
- mistralai/models/eventout.py +4 -9
- mistralai/models/fileschema.py +4 -9
- mistralai/models/fimcompletionrequest.py +11 -16
- mistralai/models/fimcompletionstreamrequest.py +11 -16
- mistralai/models/ftmodelout.py +4 -9
- mistralai/models/githubrepositoryin.py +4 -9
- mistralai/models/githubrepositoryout.py +4 -9
- mistralai/models/httpvalidationerror.py +1 -1
- mistralai/models/jobin.py +4 -9
- mistralai/models/jobmetadataout.py +4 -9
- mistralai/models/jobout.py +4 -9
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +4 -9
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +4 -9
- mistralai/models/legacyjobmetadataout.py +4 -9
- mistralai/models/metricout.py +4 -9
- mistralai/models/modelcard.py +4 -9
- mistralai/models/retrievefileout.py +4 -9
- mistralai/models/security.py +4 -4
- mistralai/models/toolmessage.py +4 -9
- mistralai/models/trainingparameters.py +4 -9
- mistralai/models/trainingparametersin.py +4 -9
- mistralai/models/updateftmodelin.py +4 -9
- mistralai/models/uploadfileout.py +4 -9
- mistralai/models/wandbintegration.py +4 -9
- mistralai/models/wandbintegrationout.py +4 -9
- mistralai/models_.py +14 -14
- mistralai/sdk.py +14 -6
- mistralai/sdkconfiguration.py +5 -4
- mistralai/types/basemodel.py +10 -6
- mistralai/utils/__init__.py +4 -0
- mistralai/utils/eventstreaming.py +8 -9
- mistralai/utils/logger.py +16 -0
- mistralai/utils/retries.py +2 -2
- mistralai/utils/security.py +5 -2
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/METADATA +113 -53
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/RECORD +96 -89
- mistralai_azure/basesdk.py +42 -4
- mistralai_azure/chat.py +15 -20
- mistralai_azure/models/__init__.py +2 -2
- mistralai_azure/models/assistantmessage.py +4 -9
- mistralai_azure/models/chatcompletionchoice.py +4 -15
- mistralai_azure/models/chatcompletionrequest.py +7 -12
- mistralai_azure/models/chatcompletionstreamrequest.py +7 -12
- mistralai_azure/models/completionresponsestreamchoice.py +4 -9
- mistralai_azure/models/deltamessage.py +4 -9
- mistralai_azure/models/httpvalidationerror.py +1 -1
- mistralai_azure/models/toolmessage.py +4 -9
- mistralai_azure/sdk.py +7 -2
- mistralai_azure/sdkconfiguration.py +5 -4
- mistralai_azure/types/basemodel.py +10 -6
- mistralai_azure/utils/__init__.py +4 -0
- mistralai_azure/utils/eventstreaming.py +8 -9
- mistralai_azure/utils/logger.py +16 -0
- mistralai_azure/utils/retries.py +2 -2
- mistralai_gcp/basesdk.py +42 -4
- mistralai_gcp/chat.py +12 -17
- mistralai_gcp/fim.py +12 -13
- mistralai_gcp/models/__init__.py +2 -2
- mistralai_gcp/models/assistantmessage.py +4 -9
- mistralai_gcp/models/chatcompletionchoice.py +4 -15
- mistralai_gcp/models/chatcompletionrequest.py +9 -14
- mistralai_gcp/models/chatcompletionstreamrequest.py +9 -14
- mistralai_gcp/models/completionresponsestreamchoice.py +4 -9
- mistralai_gcp/models/deltamessage.py +4 -9
- mistralai_gcp/models/fimcompletionrequest.py +11 -16
- mistralai_gcp/models/fimcompletionstreamrequest.py +11 -16
- mistralai_gcp/models/httpvalidationerror.py +1 -1
- mistralai_gcp/models/toolmessage.py +4 -9
- mistralai_gcp/sdk.py +9 -0
- mistralai_gcp/sdkconfiguration.py +5 -4
- mistralai_gcp/types/basemodel.py +10 -6
- mistralai_gcp/utils/__init__.py +4 -0
- mistralai_gcp/utils/eventstreaming.py +8 -9
- mistralai_gcp/utils/logger.py +16 -0
- mistralai_gcp/utils/retries.py +2 -2
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/LICENSE +0 -0
- {mistralai-0.5.5a50.dist-info → mistralai-1.0.0rc2.dist-info}/WHEEL +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from .assistantmessage import AssistantMessage, AssistantMessageRole, AssistantMessageTypedDict
|
|
4
|
-
from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceFinishReason, ChatCompletionChoiceTypedDict
|
|
4
|
+
from .chatcompletionchoice import ChatCompletionChoice, ChatCompletionChoiceFinishReason, ChatCompletionChoiceTypedDict
|
|
5
5
|
from .chatcompletionrequest import ChatCompletionRequest, ChatCompletionRequestMessages, ChatCompletionRequestMessagesTypedDict, ChatCompletionRequestStop, ChatCompletionRequestStopTypedDict, ChatCompletionRequestToolChoice, ChatCompletionRequestTypedDict
|
|
6
6
|
from .chatcompletionresponse import ChatCompletionResponse, ChatCompletionResponseTypedDict
|
|
7
7
|
from .chatcompletionstreamrequest import ChatCompletionStreamRequest, ChatCompletionStreamRequestTypedDict, Messages, MessagesTypedDict, Stop, StopTypedDict, ToolChoice
|
|
@@ -25,4 +25,4 @@ from .usageinfo import UsageInfo, UsageInfoTypedDict
|
|
|
25
25
|
from .usermessage import UserMessage, UserMessageContent, UserMessageContentTypedDict, UserMessageRole, UserMessageTypedDict
|
|
26
26
|
from .validationerror import Loc, LocTypedDict, ValidationError, ValidationErrorTypedDict
|
|
27
27
|
|
|
28
|
-
__all__ = ["AssistantMessage", "AssistantMessageRole", "AssistantMessageTypedDict", "ChatCompletionChoice", "ChatCompletionChoiceFinishReason", "ChatCompletionChoiceTypedDict", "ChatCompletionRequest", "ChatCompletionRequestMessages", "ChatCompletionRequestMessagesTypedDict", "ChatCompletionRequestStop", "ChatCompletionRequestStopTypedDict", "ChatCompletionRequestToolChoice", "ChatCompletionRequestTypedDict", "ChatCompletionResponse", "ChatCompletionResponseTypedDict", "ChatCompletionStreamRequest", "ChatCompletionStreamRequestTypedDict", "CompletionChunk", "CompletionChunkTypedDict", "CompletionEvent", "CompletionEventTypedDict", "CompletionResponseStreamChoice", "CompletionResponseStreamChoiceTypedDict", "Content", "ContentChunk", "ContentChunkTypedDict", "ContentTypedDict", "DeltaMessage", "DeltaMessageTypedDict", "FinishReason", "Function", "FunctionCall", "FunctionCallTypedDict", "FunctionTypedDict", "HTTPValidationError", "HTTPValidationErrorData", "Loc", "LocTypedDict", "
|
|
28
|
+
__all__ = ["AssistantMessage", "AssistantMessageRole", "AssistantMessageTypedDict", "ChatCompletionChoice", "ChatCompletionChoiceFinishReason", "ChatCompletionChoiceTypedDict", "ChatCompletionRequest", "ChatCompletionRequestMessages", "ChatCompletionRequestMessagesTypedDict", "ChatCompletionRequestStop", "ChatCompletionRequestStopTypedDict", "ChatCompletionRequestToolChoice", "ChatCompletionRequestTypedDict", "ChatCompletionResponse", "ChatCompletionResponseTypedDict", "ChatCompletionStreamRequest", "ChatCompletionStreamRequestTypedDict", "CompletionChunk", "CompletionChunkTypedDict", "CompletionEvent", "CompletionEventTypedDict", "CompletionResponseStreamChoice", "CompletionResponseStreamChoiceTypedDict", "Content", "ContentChunk", "ContentChunkTypedDict", "ContentTypedDict", "DeltaMessage", "DeltaMessageTypedDict", "FinishReason", "Function", "FunctionCall", "FunctionCallTypedDict", "FunctionTypedDict", "HTTPValidationError", "HTTPValidationErrorData", "Loc", "LocTypedDict", "Messages", "MessagesTypedDict", "ResponseFormat", "ResponseFormatTypedDict", "ResponseFormats", "Role", "SDKError", "Security", "SecurityTypedDict", "Stop", "StopTypedDict", "SystemMessage", "SystemMessageTypedDict", "TextChunk", "TextChunkTypedDict", "Tool", "ToolCall", "ToolCallTypedDict", "ToolChoice", "ToolMessage", "ToolMessageRole", "ToolMessageTypedDict", "ToolTypedDict", "UsageInfo", "UsageInfoTypedDict", "UserMessage", "UserMessageContent", "UserMessageContentTypedDict", "UserMessageRole", "UserMessageTypedDict", "ValidationError", "ValidationErrorTypedDict"]
|
|
@@ -39,18 +39,13 @@ class AssistantMessage(BaseModel):
|
|
|
39
39
|
k = f.alias or n
|
|
40
40
|
val = serialized.get(k)
|
|
41
41
|
|
|
42
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
43
|
+
is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
|
|
44
|
+
|
|
42
45
|
if val is not None and val != UNSET_SENTINEL:
|
|
43
46
|
m[k] = val
|
|
44
47
|
elif val != UNSET_SENTINEL and (
|
|
45
|
-
not k in optional_fields
|
|
46
|
-
or (
|
|
47
|
-
k in optional_fields
|
|
48
|
-
and k in nullable_fields
|
|
49
|
-
and (
|
|
50
|
-
self.__pydantic_fields_set__.intersection({n})
|
|
51
|
-
or k in null_default_fields
|
|
52
|
-
) # pylint: disable=no-member
|
|
53
|
-
)
|
|
48
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
54
49
|
):
|
|
55
50
|
m[k] = val
|
|
56
51
|
|
|
@@ -2,14 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
|
5
|
-
from .systemmessage import SystemMessage, SystemMessageTypedDict
|
|
6
|
-
from .toolmessage import ToolMessage, ToolMessageTypedDict
|
|
7
|
-
from .usermessage import UserMessage, UserMessageTypedDict
|
|
8
5
|
from mistralai_azure.types import BaseModel
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from typing import Literal, Optional, TypedDict, Union
|
|
12
|
-
from typing_extensions import Annotated, NotRequired
|
|
6
|
+
from typing import Literal, Optional, TypedDict
|
|
7
|
+
from typing_extensions import NotRequired
|
|
13
8
|
|
|
14
9
|
|
|
15
10
|
ChatCompletionChoiceFinishReason = Literal["stop", "length", "model_length", "error", "tool_calls"]
|
|
@@ -17,17 +12,11 @@ ChatCompletionChoiceFinishReason = Literal["stop", "length", "model_length", "er
|
|
|
17
12
|
class ChatCompletionChoiceTypedDict(TypedDict):
|
|
18
13
|
index: int
|
|
19
14
|
finish_reason: ChatCompletionChoiceFinishReason
|
|
20
|
-
message: NotRequired[
|
|
15
|
+
message: NotRequired[AssistantMessageTypedDict]
|
|
21
16
|
|
|
22
17
|
|
|
23
18
|
class ChatCompletionChoice(BaseModel):
|
|
24
19
|
index: int
|
|
25
20
|
finish_reason: ChatCompletionChoiceFinishReason
|
|
26
|
-
message: Optional[
|
|
21
|
+
message: Optional[AssistantMessage] = None
|
|
27
22
|
|
|
28
|
-
|
|
29
|
-
MessageTypedDict = Union[SystemMessageTypedDict, UserMessageTypedDict, AssistantMessageTypedDict, ToolMessageTypedDict]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Message = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]
|
|
33
|
-
|
|
@@ -37,9 +37,9 @@ class ChatCompletionRequestTypedDict(TypedDict):
|
|
|
37
37
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
38
38
|
response_format: NotRequired[ResponseFormatTypedDict]
|
|
39
39
|
tools: NotRequired[Nullable[List[ToolTypedDict]]]
|
|
40
|
+
tool_choice: NotRequired[ChatCompletionRequestToolChoice]
|
|
40
41
|
safe_prompt: NotRequired[bool]
|
|
41
42
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
42
|
-
tool_choice: NotRequired[ChatCompletionRequestToolChoice]
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
class ChatCompletionRequest(BaseModel):
|
|
@@ -63,13 +63,13 @@ class ChatCompletionRequest(BaseModel):
|
|
|
63
63
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
64
64
|
response_format: Optional[ResponseFormat] = None
|
|
65
65
|
tools: OptionalNullable[List[Tool]] = UNSET
|
|
66
|
+
tool_choice: Optional[ChatCompletionRequestToolChoice] = "auto"
|
|
66
67
|
safe_prompt: Optional[bool] = False
|
|
67
68
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
68
|
-
tool_choice: Optional[ChatCompletionRequestToolChoice] = "auto"
|
|
69
69
|
|
|
70
70
|
@model_serializer(mode="wrap")
|
|
71
71
|
def serialize_model(self, handler):
|
|
72
|
-
optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "
|
|
72
|
+
optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "tool_choice", "safe_prompt"]
|
|
73
73
|
nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "tools"]
|
|
74
74
|
null_default_fields = []
|
|
75
75
|
|
|
@@ -81,18 +81,13 @@ class ChatCompletionRequest(BaseModel):
|
|
|
81
81
|
k = f.alias or n
|
|
82
82
|
val = serialized.get(k)
|
|
83
83
|
|
|
84
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
85
|
+
is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
|
|
86
|
+
|
|
84
87
|
if val is not None and val != UNSET_SENTINEL:
|
|
85
88
|
m[k] = val
|
|
86
89
|
elif val != UNSET_SENTINEL and (
|
|
87
|
-
not k in optional_fields
|
|
88
|
-
or (
|
|
89
|
-
k in optional_fields
|
|
90
|
-
and k in nullable_fields
|
|
91
|
-
and (
|
|
92
|
-
self.__pydantic_fields_set__.intersection({n})
|
|
93
|
-
or k in null_default_fields
|
|
94
|
-
) # pylint: disable=no-member
|
|
95
|
-
)
|
|
90
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
96
91
|
):
|
|
97
92
|
m[k] = val
|
|
98
93
|
|
|
@@ -36,9 +36,9 @@ class ChatCompletionStreamRequestTypedDict(TypedDict):
|
|
|
36
36
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
37
37
|
response_format: NotRequired[ResponseFormatTypedDict]
|
|
38
38
|
tools: NotRequired[Nullable[List[ToolTypedDict]]]
|
|
39
|
+
tool_choice: NotRequired[ToolChoice]
|
|
39
40
|
safe_prompt: NotRequired[bool]
|
|
40
41
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
41
|
-
tool_choice: NotRequired[ToolChoice]
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
class ChatCompletionStreamRequest(BaseModel):
|
|
@@ -61,13 +61,13 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
61
61
|
r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
|
|
62
62
|
response_format: Optional[ResponseFormat] = None
|
|
63
63
|
tools: OptionalNullable[List[Tool]] = UNSET
|
|
64
|
+
tool_choice: Optional[ToolChoice] = "auto"
|
|
64
65
|
safe_prompt: Optional[bool] = False
|
|
65
66
|
r"""Whether to inject a safety prompt before all conversations."""
|
|
66
|
-
tool_choice: Optional[ToolChoice] = "auto"
|
|
67
67
|
|
|
68
68
|
@model_serializer(mode="wrap")
|
|
69
69
|
def serialize_model(self, handler):
|
|
70
|
-
optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "
|
|
70
|
+
optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "response_format", "tools", "tool_choice", "safe_prompt"]
|
|
71
71
|
nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "tools"]
|
|
72
72
|
null_default_fields = []
|
|
73
73
|
|
|
@@ -79,18 +79,13 @@ class ChatCompletionStreamRequest(BaseModel):
|
|
|
79
79
|
k = f.alias or n
|
|
80
80
|
val = serialized.get(k)
|
|
81
81
|
|
|
82
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
83
|
+
is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
|
|
84
|
+
|
|
82
85
|
if val is not None and val != UNSET_SENTINEL:
|
|
83
86
|
m[k] = val
|
|
84
87
|
elif val != UNSET_SENTINEL and (
|
|
85
|
-
not k in optional_fields
|
|
86
|
-
or (
|
|
87
|
-
k in optional_fields
|
|
88
|
-
and k in nullable_fields
|
|
89
|
-
and (
|
|
90
|
-
self.__pydantic_fields_set__.intersection({n})
|
|
91
|
-
or k in null_default_fields
|
|
92
|
-
) # pylint: disable=no-member
|
|
93
|
-
)
|
|
88
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
94
89
|
):
|
|
95
90
|
m[k] = val
|
|
96
91
|
|
|
@@ -34,18 +34,13 @@ class CompletionResponseStreamChoice(BaseModel):
|
|
|
34
34
|
k = f.alias or n
|
|
35
35
|
val = serialized.get(k)
|
|
36
36
|
|
|
37
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
38
|
+
is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
|
|
39
|
+
|
|
37
40
|
if val is not None and val != UNSET_SENTINEL:
|
|
38
41
|
m[k] = val
|
|
39
42
|
elif val != UNSET_SENTINEL and (
|
|
40
|
-
not k in optional_fields
|
|
41
|
-
or (
|
|
42
|
-
k in optional_fields
|
|
43
|
-
and k in nullable_fields
|
|
44
|
-
and (
|
|
45
|
-
self.__pydantic_fields_set__.intersection({n})
|
|
46
|
-
or k in null_default_fields
|
|
47
|
-
) # pylint: disable=no-member
|
|
48
|
-
)
|
|
43
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
49
44
|
):
|
|
50
45
|
m[k] = val
|
|
51
46
|
|
|
@@ -33,18 +33,13 @@ class DeltaMessage(BaseModel):
|
|
|
33
33
|
k = f.alias or n
|
|
34
34
|
val = serialized.get(k)
|
|
35
35
|
|
|
36
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
37
|
+
is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
|
|
38
|
+
|
|
36
39
|
if val is not None and val != UNSET_SENTINEL:
|
|
37
40
|
m[k] = val
|
|
38
41
|
elif val != UNSET_SENTINEL and (
|
|
39
|
-
not k in optional_fields
|
|
40
|
-
or (
|
|
41
|
-
k in optional_fields
|
|
42
|
-
and k in nullable_fields
|
|
43
|
-
and (
|
|
44
|
-
self.__pydantic_fields_set__.intersection({n})
|
|
45
|
-
or k in null_default_fields
|
|
46
|
-
) # pylint: disable=no-member
|
|
47
|
-
)
|
|
42
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
48
43
|
):
|
|
49
44
|
m[k] = val
|
|
50
45
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .validationerror import ValidationError
|
|
5
|
+
from mistralai_azure import utils
|
|
5
6
|
from mistralai_azure.types import BaseModel
|
|
6
|
-
import mistralai_azure.utils as utils
|
|
7
7
|
from typing import List, Optional
|
|
8
8
|
|
|
9
9
|
class HTTPValidationErrorData(BaseModel):
|
|
@@ -36,18 +36,13 @@ class ToolMessage(BaseModel):
|
|
|
36
36
|
k = f.alias or n
|
|
37
37
|
val = serialized.get(k)
|
|
38
38
|
|
|
39
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
40
|
+
is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
|
|
41
|
+
|
|
39
42
|
if val is not None and val != UNSET_SENTINEL:
|
|
40
43
|
m[k] = val
|
|
41
44
|
elif val != UNSET_SENTINEL and (
|
|
42
|
-
not k in optional_fields
|
|
43
|
-
or (
|
|
44
|
-
k in optional_fields
|
|
45
|
-
and k in nullable_fields
|
|
46
|
-
and (
|
|
47
|
-
self.__pydantic_fields_set__.intersection({n})
|
|
48
|
-
or k in null_default_fields
|
|
49
|
-
) # pylint: disable=no-member
|
|
50
|
-
)
|
|
45
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
51
46
|
):
|
|
52
47
|
m[k] = val
|
|
53
48
|
|
mistralai_azure/sdk.py
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
from typing import Any, Callable, Dict, Optional, Union
|
|
4
4
|
|
|
5
5
|
import httpx
|
|
6
|
-
|
|
7
|
-
from mistralai_azure import models
|
|
6
|
+
from mistralai_azure import models, utils
|
|
8
7
|
from mistralai_azure._hooks import SDKHooks
|
|
9
8
|
from mistralai_azure.chat import Chat
|
|
10
9
|
from mistralai_azure.types import Nullable
|
|
@@ -12,6 +11,7 @@ from mistralai_azure.types import Nullable
|
|
|
12
11
|
from .basesdk import BaseSDK
|
|
13
12
|
from .httpclient import AsyncHttpClient, HttpClient
|
|
14
13
|
from .sdkconfiguration import SDKConfiguration
|
|
14
|
+
from .utils.logger import Logger, NoOpLogger
|
|
15
15
|
from .utils.retries import RetryConfig
|
|
16
16
|
|
|
17
17
|
|
|
@@ -29,6 +29,7 @@ class MistralAzure(BaseSDK):
|
|
|
29
29
|
client: Optional[HttpClient] = None,
|
|
30
30
|
async_client: Optional[AsyncHttpClient] = None,
|
|
31
31
|
retry_config: Optional[Nullable[RetryConfig]] = None,
|
|
32
|
+
debug_logger: Optional[Logger] = None,
|
|
32
33
|
) -> None:
|
|
33
34
|
r"""Instantiates the SDK configuring it with the provided parameters.
|
|
34
35
|
|
|
@@ -60,6 +61,9 @@ class MistralAzure(BaseSDK):
|
|
|
60
61
|
type(async_client), AsyncHttpClient
|
|
61
62
|
), "The provided async_client must implement the AsyncHttpClient protocol."
|
|
62
63
|
|
|
64
|
+
if debug_logger is None:
|
|
65
|
+
debug_logger = NoOpLogger()
|
|
66
|
+
|
|
63
67
|
security: Any = None
|
|
64
68
|
if callable(azure_api_key):
|
|
65
69
|
security = lambda: models.Security( # pylint: disable=unnecessary-lambda-assignment
|
|
@@ -81,6 +85,7 @@ class MistralAzure(BaseSDK):
|
|
|
81
85
|
server_url=server_url,
|
|
82
86
|
server=None,
|
|
83
87
|
retry_config=retry_config,
|
|
88
|
+
debug_logger=debug_logger,
|
|
84
89
|
),
|
|
85
90
|
)
|
|
86
91
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
from ._hooks import SDKHooks
|
|
5
5
|
from .httpclient import AsyncHttpClient, HttpClient
|
|
6
|
-
from .utils import RetryConfig, remove_suffix
|
|
6
|
+
from .utils import Logger, RetryConfig, remove_suffix
|
|
7
7
|
from dataclasses import dataclass
|
|
8
8
|
from mistralai_azure import models
|
|
9
9
|
from mistralai_azure.types import OptionalNullable, UNSET
|
|
@@ -23,14 +23,15 @@ SERVERS = {
|
|
|
23
23
|
class SDKConfiguration:
|
|
24
24
|
client: HttpClient
|
|
25
25
|
async_client: AsyncHttpClient
|
|
26
|
+
debug_logger: Logger
|
|
26
27
|
security: Optional[Union[models.Security,Callable[[], models.Security]]] = None
|
|
27
28
|
server_url: Optional[str] = ""
|
|
28
29
|
server: Optional[str] = ""
|
|
29
30
|
language: str = "python"
|
|
30
31
|
openapi_doc_version: str = "0.0.2"
|
|
31
|
-
sdk_version: str = "0.
|
|
32
|
-
gen_version: str = "2.
|
|
33
|
-
user_agent: str = "speakeasy-sdk/python 0.
|
|
32
|
+
sdk_version: str = "1.0.0-alpha.13"
|
|
33
|
+
gen_version: str = "2.386.0"
|
|
34
|
+
user_agent: str = "speakeasy-sdk/python 1.0.0-alpha.13 2.386.0 0.0.2 mistralai_azure"
|
|
34
35
|
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
|
35
36
|
timeout_ms: Optional[int] = None
|
|
36
37
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from pydantic import ConfigDict, model_serializer
|
|
4
4
|
from pydantic import BaseModel as PydanticBaseModel
|
|
5
|
-
from typing import Literal, Optional, TypeVar, Union, NewType
|
|
6
|
-
from typing_extensions import TypeAliasType
|
|
5
|
+
from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union, NewType
|
|
6
|
+
from typing_extensions import TypeAliasType, TypeAlias
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class BaseModel(PydanticBaseModel):
|
|
@@ -26,10 +26,14 @@ UNSET_SENTINEL = "~?~unset~?~sentinel~?~"
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
T = TypeVar("T")
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
Nullable: TypeAlias = Union[T, None]
|
|
31
|
+
OptionalNullable: TypeAlias = Union[Optional[Nullable[T]], Unset]
|
|
32
|
+
else:
|
|
33
|
+
Nullable = TypeAliasType("Nullable", Union[T, None], type_params=(T,))
|
|
34
|
+
OptionalNullable = TypeAliasType(
|
|
35
|
+
"OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
|
|
36
|
+
)
|
|
33
37
|
|
|
34
38
|
UnrecognizedInt = NewType("UnrecognizedInt", int)
|
|
35
39
|
UnrecognizedStr = NewType("UnrecognizedStr", str)
|
|
@@ -34,6 +34,7 @@ from .serializers import (
|
|
|
34
34
|
)
|
|
35
35
|
from .url import generate_url, template_url, remove_suffix
|
|
36
36
|
from .values import get_global_from_env, match_content_type, match_status_codes, match_response
|
|
37
|
+
from .logger import Logger, get_body_content, NoOpLogger
|
|
37
38
|
|
|
38
39
|
__all__ = [
|
|
39
40
|
"BackoffStrategy",
|
|
@@ -41,6 +42,7 @@ __all__ = [
|
|
|
41
42
|
"find_metadata",
|
|
42
43
|
"FormMetadata",
|
|
43
44
|
"generate_url",
|
|
45
|
+
"get_body_content",
|
|
44
46
|
"get_discriminator",
|
|
45
47
|
"get_global_from_env",
|
|
46
48
|
"get_headers",
|
|
@@ -49,11 +51,13 @@ __all__ = [
|
|
|
49
51
|
"get_response_headers",
|
|
50
52
|
"get_security",
|
|
51
53
|
"HeaderMetadata",
|
|
54
|
+
"Logger",
|
|
52
55
|
"marshal_json",
|
|
53
56
|
"match_content_type",
|
|
54
57
|
"match_status_codes",
|
|
55
58
|
"match_response",
|
|
56
59
|
"MultipartFormMetadata",
|
|
60
|
+
"NoOpLogger",
|
|
57
61
|
"OpenEnumMeta",
|
|
58
62
|
"PathParamMetadata",
|
|
59
63
|
"QueryParamMetadata",
|
|
@@ -147,15 +147,14 @@ def _parse_event(
|
|
|
147
147
|
data = data[:-1]
|
|
148
148
|
event.data = data
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
data.isnumeric()
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
or data
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
):
|
|
150
|
+
data_is_primitive = (
|
|
151
|
+
data.isnumeric() or data == "true" or data == "false" or data == "null"
|
|
152
|
+
)
|
|
153
|
+
data_is_json = (
|
|
154
|
+
data.startswith("{") or data.startswith("[") or data.startswith('"')
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
if data_is_primitive or data_is_json:
|
|
159
158
|
try:
|
|
160
159
|
event.data = json.loads(data)
|
|
161
160
|
except Exception:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
import httpx
|
|
4
|
+
from typing import Any, Protocol
|
|
5
|
+
|
|
6
|
+
class Logger(Protocol):
|
|
7
|
+
def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
class NoOpLogger:
|
|
11
|
+
def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
def get_body_content(req: httpx.Request) -> str:
|
|
15
|
+
return "<streaming body>" if not hasattr(req, "_content") else str(req.content)
|
|
16
|
+
|
mistralai_azure/utils/retries.py
CHANGED
|
@@ -76,7 +76,7 @@ def retry(func, retries: Retries):
|
|
|
76
76
|
|
|
77
77
|
status_major = res.status_code / 100
|
|
78
78
|
|
|
79
|
-
if
|
|
79
|
+
if code_range <= status_major < code_range + 1:
|
|
80
80
|
raise TemporaryError(res)
|
|
81
81
|
else:
|
|
82
82
|
parsed_code = int(code)
|
|
@@ -125,7 +125,7 @@ async def retry_async(func, retries: Retries):
|
|
|
125
125
|
|
|
126
126
|
status_major = res.status_code / 100
|
|
127
127
|
|
|
128
|
-
if
|
|
128
|
+
if code_range <= status_major < code_range + 1:
|
|
129
129
|
raise TemporaryError(res)
|
|
130
130
|
else:
|
|
131
131
|
parsed_code = int(code)
|
mistralai_gcp/basesdk.py
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
from .sdkconfiguration import SDKConfiguration
|
|
4
4
|
import httpx
|
|
5
|
-
from mistralai_gcp import models
|
|
5
|
+
from mistralai_gcp import models, utils
|
|
6
6
|
from mistralai_gcp._hooks import AfterErrorContext, AfterSuccessContext, BeforeRequestContext
|
|
7
|
-
|
|
8
|
-
from mistralai_gcp.utils import RetryConfig, SerializedRequestBody
|
|
7
|
+
from mistralai_gcp.utils import RetryConfig, SerializedRequestBody, get_body_content
|
|
9
8
|
from typing import Callable, List, Optional, Tuple
|
|
10
9
|
|
|
11
10
|
class BaseSDK:
|
|
@@ -117,6 +116,7 @@ class BaseSDK:
|
|
|
117
116
|
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
|
118
117
|
) -> httpx.Response:
|
|
119
118
|
client = self.sdk_configuration.client
|
|
119
|
+
logger = self.sdk_configuration.debug_logger
|
|
120
120
|
|
|
121
121
|
def do():
|
|
122
122
|
http_res = None
|
|
@@ -124,26 +124,45 @@ class BaseSDK:
|
|
|
124
124
|
req = self.sdk_configuration.get_hooks().before_request(
|
|
125
125
|
BeforeRequestContext(hook_ctx), request
|
|
126
126
|
)
|
|
127
|
+
logger.debug(
|
|
128
|
+
"Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
|
129
|
+
req.method,
|
|
130
|
+
req.url,
|
|
131
|
+
req.headers,
|
|
132
|
+
get_body_content(req)
|
|
133
|
+
)
|
|
127
134
|
http_res = client.send(req, stream=stream)
|
|
128
135
|
except Exception as e:
|
|
129
136
|
_, e = self.sdk_configuration.get_hooks().after_error(
|
|
130
137
|
AfterErrorContext(hook_ctx), None, e
|
|
131
138
|
)
|
|
132
139
|
if e is not None:
|
|
140
|
+
logger.debug("Request Exception", exc_info=True)
|
|
133
141
|
raise e
|
|
134
142
|
|
|
135
143
|
if http_res is None:
|
|
144
|
+
logger.debug("Raising no response SDK error")
|
|
136
145
|
raise models.SDKError("No response received")
|
|
137
146
|
|
|
147
|
+
logger.debug(
|
|
148
|
+
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
|
149
|
+
http_res.status_code,
|
|
150
|
+
http_res.url,
|
|
151
|
+
http_res.headers,
|
|
152
|
+
"<streaming response>" if stream else http_res.text
|
|
153
|
+
)
|
|
154
|
+
|
|
138
155
|
if utils.match_status_codes(error_status_codes, http_res.status_code):
|
|
139
156
|
result, err = self.sdk_configuration.get_hooks().after_error(
|
|
140
157
|
AfterErrorContext(hook_ctx), http_res, None
|
|
141
158
|
)
|
|
142
159
|
if err is not None:
|
|
160
|
+
logger.debug("Request Exception", exc_info=True)
|
|
143
161
|
raise err
|
|
144
162
|
if result is not None:
|
|
145
163
|
http_res = result
|
|
146
164
|
else:
|
|
165
|
+
logger.debug("Raising unexpected SDK error")
|
|
147
166
|
raise models.SDKError("Unexpected error occurred")
|
|
148
167
|
|
|
149
168
|
return http_res
|
|
@@ -169,33 +188,52 @@ class BaseSDK:
|
|
|
169
188
|
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
|
|
170
189
|
) -> httpx.Response:
|
|
171
190
|
client = self.sdk_configuration.async_client
|
|
172
|
-
|
|
191
|
+
logger = self.sdk_configuration.debug_logger
|
|
173
192
|
async def do():
|
|
174
193
|
http_res = None
|
|
175
194
|
try:
|
|
176
195
|
req = self.sdk_configuration.get_hooks().before_request(
|
|
177
196
|
BeforeRequestContext(hook_ctx), request
|
|
178
197
|
)
|
|
198
|
+
logger.debug(
|
|
199
|
+
"Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
|
200
|
+
req.method,
|
|
201
|
+
req.url,
|
|
202
|
+
req.headers,
|
|
203
|
+
get_body_content(req)
|
|
204
|
+
)
|
|
179
205
|
http_res = await client.send(req, stream=stream)
|
|
180
206
|
except Exception as e:
|
|
181
207
|
_, e = self.sdk_configuration.get_hooks().after_error(
|
|
182
208
|
AfterErrorContext(hook_ctx), None, e
|
|
183
209
|
)
|
|
184
210
|
if e is not None:
|
|
211
|
+
logger.debug("Request Exception", exc_info=True)
|
|
185
212
|
raise e
|
|
186
213
|
|
|
187
214
|
if http_res is None:
|
|
215
|
+
logger.debug("Raising no response SDK error")
|
|
188
216
|
raise models.SDKError("No response received")
|
|
189
217
|
|
|
218
|
+
logger.debug(
|
|
219
|
+
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
|
|
220
|
+
http_res.status_code,
|
|
221
|
+
http_res.url,
|
|
222
|
+
http_res.headers,
|
|
223
|
+
"<streaming response>" if stream else http_res.text
|
|
224
|
+
)
|
|
225
|
+
|
|
190
226
|
if utils.match_status_codes(error_status_codes, http_res.status_code):
|
|
191
227
|
result, err = self.sdk_configuration.get_hooks().after_error(
|
|
192
228
|
AfterErrorContext(hook_ctx), http_res, None
|
|
193
229
|
)
|
|
194
230
|
if err is not None:
|
|
231
|
+
logger.debug("Request Exception", exc_info=True)
|
|
195
232
|
raise err
|
|
196
233
|
if result is not None:
|
|
197
234
|
http_res = result
|
|
198
235
|
else:
|
|
236
|
+
logger.debug("Raising unexpected SDK error")
|
|
199
237
|
raise models.SDKError("Unexpected error occurred")
|
|
200
238
|
|
|
201
239
|
return http_res
|