mistralai 1.10.0__py3-none-any.whl → 1.11.1__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/_hooks/tracing.py +28 -3
- mistralai/_version.py +3 -3
- mistralai/accesses.py +22 -12
- mistralai/agents.py +88 -44
- mistralai/basesdk.py +6 -0
- mistralai/chat.py +96 -40
- mistralai/classifiers.py +48 -23
- mistralai/conversations.py +186 -64
- mistralai/documents.py +72 -26
- mistralai/embeddings.py +24 -9
- mistralai/extra/README.md +1 -1
- mistralai/extra/mcp/auth.py +10 -11
- mistralai/extra/mcp/base.py +17 -16
- mistralai/extra/mcp/sse.py +13 -15
- mistralai/extra/mcp/stdio.py +5 -6
- mistralai/extra/observability/otel.py +47 -68
- mistralai/extra/run/context.py +33 -43
- mistralai/extra/run/result.py +29 -30
- mistralai/extra/run/tools.py +8 -9
- mistralai/extra/struct_chat.py +15 -8
- mistralai/extra/utils/response_format.py +5 -3
- mistralai/files.py +58 -24
- mistralai/fim.py +20 -12
- mistralai/httpclient.py +0 -1
- mistralai/jobs.py +65 -26
- mistralai/libraries.py +20 -10
- mistralai/mistral_agents.py +438 -30
- mistralai/mistral_jobs.py +62 -17
- mistralai/models/__init__.py +46 -1
- mistralai/models/agent.py +1 -1
- mistralai/models/agentconversation.py +1 -1
- mistralai/models/agenthandoffdoneevent.py +1 -1
- mistralai/models/agenthandoffentry.py +3 -2
- mistralai/models/agenthandoffstartedevent.py +1 -1
- mistralai/models/agents_api_v1_agents_get_versionop.py +21 -0
- mistralai/models/agents_api_v1_agents_list_versionsop.py +33 -0
- mistralai/models/agents_api_v1_agents_listop.py +5 -1
- mistralai/models/agents_api_v1_conversations_listop.py +1 -1
- mistralai/models/agentscompletionrequest.py +2 -5
- mistralai/models/agentscompletionstreamrequest.py +2 -5
- mistralai/models/archiveftmodelout.py +1 -1
- mistralai/models/assistantmessage.py +1 -1
- mistralai/models/audiochunk.py +1 -1
- mistralai/models/audioencoding.py +18 -0
- mistralai/models/audioformat.py +17 -0
- mistralai/models/basemodelcard.py +1 -1
- mistralai/models/batchjobin.py +18 -9
- mistralai/models/batchjobout.py +6 -1
- mistralai/models/batchjobsout.py +1 -1
- mistralai/models/batchrequest.py +48 -0
- mistralai/models/chatcompletionchoice.py +10 -5
- mistralai/models/chatcompletionrequest.py +2 -5
- mistralai/models/chatcompletionstreamrequest.py +2 -5
- mistralai/models/classificationrequest.py +37 -3
- mistralai/models/classifierdetailedjobout.py +4 -2
- mistralai/models/classifierftmodelout.py +3 -2
- mistralai/models/classifierjobout.py +4 -2
- mistralai/models/codeinterpretertool.py +1 -1
- mistralai/models/completiondetailedjobout.py +5 -2
- mistralai/models/completionftmodelout.py +3 -2
- mistralai/models/completionjobout.py +5 -2
- mistralai/models/completionresponsestreamchoice.py +9 -8
- mistralai/models/conversationappendrequest.py +4 -1
- mistralai/models/conversationappendstreamrequest.py +4 -1
- mistralai/models/conversationhistory.py +2 -1
- mistralai/models/conversationmessages.py +1 -1
- mistralai/models/conversationrequest.py +5 -1
- mistralai/models/conversationresponse.py +2 -1
- mistralai/models/conversationrestartrequest.py +4 -1
- mistralai/models/conversationrestartstreamrequest.py +4 -1
- mistralai/models/conversationstreamrequest.py +5 -1
- mistralai/models/documentlibrarytool.py +1 -1
- mistralai/models/documenturlchunk.py +1 -1
- mistralai/models/embeddingdtype.py +7 -1
- mistralai/models/embeddingrequest.py +11 -3
- mistralai/models/encodingformat.py +4 -1
- mistralai/models/entitytype.py +8 -1
- mistralai/models/filepurpose.py +8 -1
- mistralai/models/files_api_routes_list_filesop.py +4 -11
- mistralai/models/files_api_routes_upload_fileop.py +2 -6
- mistralai/models/fileschema.py +3 -5
- mistralai/models/finetuneablemodeltype.py +4 -1
- mistralai/models/ftclassifierlossfunction.py +4 -1
- mistralai/models/ftmodelcard.py +1 -1
- mistralai/models/functioncallentry.py +3 -2
- mistralai/models/functioncallevent.py +1 -1
- mistralai/models/functionresultentry.py +3 -2
- mistralai/models/functiontool.py +1 -1
- mistralai/models/githubrepositoryin.py +1 -1
- mistralai/models/githubrepositoryout.py +1 -1
- mistralai/models/httpvalidationerror.py +4 -2
- mistralai/models/imagegenerationtool.py +1 -1
- mistralai/models/imageurlchunk.py +1 -1
- mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +40 -3
- mistralai/models/jobsout.py +1 -1
- mistralai/models/legacyjobmetadataout.py +1 -1
- mistralai/models/messageinputentry.py +9 -3
- mistralai/models/messageoutputentry.py +6 -3
- mistralai/models/messageoutputevent.py +4 -2
- mistralai/models/mistralerror.py +11 -7
- mistralai/models/mistralpromptmode.py +1 -1
- mistralai/models/modelconversation.py +1 -1
- mistralai/models/no_response_error.py +5 -1
- mistralai/models/ocrrequest.py +11 -1
- mistralai/models/ocrtableobject.py +4 -1
- mistralai/models/referencechunk.py +1 -1
- mistralai/models/requestsource.py +5 -1
- mistralai/models/responsedoneevent.py +1 -1
- mistralai/models/responseerrorevent.py +1 -1
- mistralai/models/responseformats.py +5 -1
- mistralai/models/responsestartedevent.py +1 -1
- mistralai/models/responsevalidationerror.py +2 -0
- mistralai/models/retrievefileout.py +3 -5
- mistralai/models/sampletype.py +7 -1
- mistralai/models/sdkerror.py +2 -0
- mistralai/models/shareenum.py +7 -1
- mistralai/models/sharingdelete.py +2 -4
- mistralai/models/sharingin.py +3 -5
- mistralai/models/source.py +8 -1
- mistralai/models/systemmessage.py +1 -1
- mistralai/models/textchunk.py +1 -1
- mistralai/models/thinkchunk.py +1 -1
- mistralai/models/timestampgranularity.py +1 -1
- mistralai/models/tool.py +2 -6
- mistralai/models/toolcall.py +2 -6
- mistralai/models/toolchoice.py +2 -6
- mistralai/models/toolchoiceenum.py +6 -1
- mistralai/models/toolexecutiondeltaevent.py +2 -1
- mistralai/models/toolexecutiondoneevent.py +2 -1
- mistralai/models/toolexecutionentry.py +4 -2
- mistralai/models/toolexecutionstartedevent.py +2 -1
- mistralai/models/toolfilechunk.py +13 -5
- mistralai/models/toolmessage.py +1 -1
- mistralai/models/toolreferencechunk.py +15 -5
- mistralai/models/tooltypes.py +1 -1
- mistralai/models/transcriptionsegmentchunk.py +1 -1
- mistralai/models/transcriptionstreamdone.py +1 -1
- mistralai/models/transcriptionstreamlanguage.py +1 -1
- mistralai/models/transcriptionstreamsegmentdelta.py +1 -1
- mistralai/models/transcriptionstreamtextdelta.py +1 -1
- mistralai/models/unarchiveftmodelout.py +1 -1
- mistralai/models/uploadfileout.py +3 -5
- mistralai/models/usermessage.py +1 -1
- mistralai/models/wandbintegration.py +1 -1
- mistralai/models/wandbintegrationout.py +1 -1
- mistralai/models/websearchpremiumtool.py +1 -1
- mistralai/models/websearchtool.py +1 -1
- mistralai/models_.py +24 -12
- mistralai/ocr.py +38 -10
- mistralai/sdk.py +2 -2
- mistralai/transcriptions.py +28 -12
- mistralai/types/basemodel.py +41 -3
- mistralai/utils/__init__.py +0 -3
- mistralai/utils/annotations.py +32 -8
- mistralai/utils/enums.py +60 -0
- mistralai/utils/forms.py +21 -10
- mistralai/utils/queryparams.py +14 -2
- mistralai/utils/requestbodies.py +3 -3
- mistralai/utils/retries.py +69 -5
- mistralai/utils/serializers.py +0 -20
- mistralai/utils/unmarshal_json_response.py +15 -1
- {mistralai-1.10.0.dist-info → mistralai-1.11.1.dist-info}/METADATA +144 -159
- mistralai-1.11.1.dist-info/RECORD +495 -0
- {mistralai-1.10.0.dist-info → mistralai-1.11.1.dist-info}/WHEEL +1 -1
- mistralai_azure/_version.py +3 -3
- mistralai_azure/basesdk.py +21 -5
- mistralai_azure/chat.py +82 -109
- mistralai_azure/httpclient.py +0 -1
- mistralai_azure/models/__init__.py +66 -4
- mistralai_azure/models/assistantmessage.py +1 -1
- mistralai_azure/models/chatcompletionchoice.py +10 -7
- mistralai_azure/models/chatcompletionrequest.py +24 -10
- mistralai_azure/models/chatcompletionstreamrequest.py +24 -10
- mistralai_azure/models/completionresponsestreamchoice.py +11 -7
- mistralai_azure/models/documenturlchunk.py +1 -1
- mistralai_azure/models/httpvalidationerror.py +15 -8
- mistralai_azure/models/imageurlchunk.py +1 -1
- mistralai_azure/models/mistralazureerror.py +30 -0
- mistralai_azure/models/mistralpromptmode.py +1 -1
- mistralai_azure/models/no_response_error.py +17 -0
- mistralai_azure/models/ocrpageobject.py +32 -5
- mistralai_azure/models/ocrrequest.py +20 -1
- mistralai_azure/models/ocrtableobject.py +34 -0
- mistralai_azure/models/prediction.py +4 -0
- mistralai_azure/models/referencechunk.py +1 -1
- mistralai_azure/models/responseformat.py +4 -2
- mistralai_azure/models/responseformats.py +5 -2
- mistralai_azure/models/responsevalidationerror.py +27 -0
- mistralai_azure/models/sdkerror.py +32 -14
- mistralai_azure/models/systemmessage.py +8 -4
- mistralai_azure/models/systemmessagecontentchunks.py +21 -0
- mistralai_azure/models/textchunk.py +1 -1
- mistralai_azure/models/thinkchunk.py +35 -0
- mistralai_azure/models/tool.py +2 -6
- mistralai_azure/models/toolcall.py +2 -6
- mistralai_azure/models/toolchoice.py +2 -6
- mistralai_azure/models/toolchoiceenum.py +6 -1
- mistralai_azure/models/toolmessage.py +1 -1
- mistralai_azure/models/tooltypes.py +1 -1
- mistralai_azure/models/usermessage.py +1 -1
- mistralai_azure/ocr.py +39 -40
- mistralai_azure/types/basemodel.py +41 -3
- mistralai_azure/utils/__init__.py +18 -8
- mistralai_azure/utils/annotations.py +32 -8
- mistralai_azure/utils/enums.py +60 -0
- mistralai_azure/utils/eventstreaming.py +10 -0
- mistralai_azure/utils/forms.py +21 -10
- mistralai_azure/utils/queryparams.py +14 -2
- mistralai_azure/utils/requestbodies.py +3 -3
- mistralai_azure/utils/retries.py +69 -5
- mistralai_azure/utils/serializers.py +3 -22
- mistralai_azure/utils/unmarshal_json_response.py +38 -0
- mistralai_gcp/_hooks/types.py +7 -0
- mistralai_gcp/_version.py +4 -4
- mistralai_gcp/basesdk.py +33 -25
- mistralai_gcp/chat.py +98 -109
- mistralai_gcp/fim.py +62 -85
- mistralai_gcp/httpclient.py +6 -17
- mistralai_gcp/models/__init__.py +321 -116
- mistralai_gcp/models/assistantmessage.py +2 -2
- mistralai_gcp/models/chatcompletionchoice.py +10 -7
- mistralai_gcp/models/chatcompletionrequest.py +38 -7
- mistralai_gcp/models/chatcompletionresponse.py +6 -6
- mistralai_gcp/models/chatcompletionstreamrequest.py +38 -7
- mistralai_gcp/models/completionresponsestreamchoice.py +12 -8
- mistralai_gcp/models/deltamessage.py +1 -1
- mistralai_gcp/models/fimcompletionrequest.py +9 -10
- mistralai_gcp/models/fimcompletionresponse.py +6 -6
- mistralai_gcp/models/fimcompletionstreamrequest.py +9 -10
- mistralai_gcp/models/httpvalidationerror.py +15 -8
- mistralai_gcp/models/imageurl.py +1 -1
- mistralai_gcp/models/imageurlchunk.py +1 -1
- mistralai_gcp/models/jsonschema.py +1 -1
- mistralai_gcp/models/mistralgcperror.py +30 -0
- mistralai_gcp/models/mistralpromptmode.py +8 -0
- mistralai_gcp/models/no_response_error.py +17 -0
- mistralai_gcp/models/prediction.py +4 -0
- mistralai_gcp/models/referencechunk.py +1 -1
- mistralai_gcp/models/responseformat.py +5 -3
- mistralai_gcp/models/responseformats.py +5 -2
- mistralai_gcp/models/responsevalidationerror.py +27 -0
- mistralai_gcp/models/sdkerror.py +32 -14
- mistralai_gcp/models/systemmessage.py +8 -4
- mistralai_gcp/models/systemmessagecontentchunks.py +21 -0
- mistralai_gcp/models/textchunk.py +1 -1
- mistralai_gcp/models/thinkchunk.py +35 -0
- mistralai_gcp/models/tool.py +2 -6
- mistralai_gcp/models/toolcall.py +2 -6
- mistralai_gcp/models/toolchoice.py +2 -6
- mistralai_gcp/models/toolchoiceenum.py +6 -1
- mistralai_gcp/models/toolmessage.py +2 -2
- mistralai_gcp/models/tooltypes.py +1 -1
- mistralai_gcp/models/usageinfo.py +71 -8
- mistralai_gcp/models/usermessage.py +2 -2
- mistralai_gcp/sdk.py +12 -10
- mistralai_gcp/sdkconfiguration.py +0 -7
- mistralai_gcp/types/basemodel.py +41 -3
- mistralai_gcp/utils/__init__.py +141 -46
- mistralai_gcp/utils/annotations.py +32 -8
- mistralai_gcp/utils/datetimes.py +23 -0
- mistralai_gcp/utils/enums.py +125 -25
- mistralai_gcp/utils/eventstreaming.py +10 -0
- mistralai_gcp/utils/forms.py +62 -30
- mistralai_gcp/utils/queryparams.py +14 -2
- mistralai_gcp/utils/requestbodies.py +3 -3
- mistralai_gcp/utils/retries.py +69 -5
- mistralai_gcp/utils/serializers.py +33 -23
- mistralai_gcp/utils/unmarshal_json_response.py +38 -0
- mistralai-1.10.0.dist-info/RECORD +0 -475
- {mistralai-1.10.0.dist-info → mistralai-1.11.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from .
|
|
4
|
+
from .systemmessagecontentchunks import (
|
|
5
|
+
SystemMessageContentChunks,
|
|
6
|
+
SystemMessageContentChunksTypedDict,
|
|
7
|
+
)
|
|
5
8
|
from mistralai_gcp.types import BaseModel
|
|
6
9
|
from typing import List, Literal, Optional, Union
|
|
7
10
|
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
|
8
11
|
|
|
9
12
|
|
|
10
13
|
SystemMessageContentTypedDict = TypeAliasType(
|
|
11
|
-
"SystemMessageContentTypedDict",
|
|
14
|
+
"SystemMessageContentTypedDict",
|
|
15
|
+
Union[str, List[SystemMessageContentChunksTypedDict]],
|
|
12
16
|
)
|
|
13
17
|
|
|
14
18
|
|
|
15
19
|
SystemMessageContent = TypeAliasType(
|
|
16
|
-
"SystemMessageContent", Union[str, List[
|
|
20
|
+
"SystemMessageContent", Union[str, List[SystemMessageContentChunks]]
|
|
17
21
|
)
|
|
18
22
|
|
|
19
23
|
|
|
20
|
-
Role = Literal["system"]
|
|
24
|
+
Role = Literal["system",]
|
|
21
25
|
|
|
22
26
|
|
|
23
27
|
class SystemMessageTypedDict(TypedDict):
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .textchunk import TextChunk, TextChunkTypedDict
|
|
5
|
+
from .thinkchunk import ThinkChunk, ThinkChunkTypedDict
|
|
6
|
+
from mistralai_gcp.utils import get_discriminator
|
|
7
|
+
from pydantic import Discriminator, Tag
|
|
8
|
+
from typing import Union
|
|
9
|
+
from typing_extensions import Annotated, TypeAliasType
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
SystemMessageContentChunksTypedDict = TypeAliasType(
|
|
13
|
+
"SystemMessageContentChunksTypedDict",
|
|
14
|
+
Union[TextChunkTypedDict, ThinkChunkTypedDict],
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
SystemMessageContentChunks = Annotated[
|
|
19
|
+
Union[Annotated[TextChunk, Tag("text")], Annotated[ThinkChunk, Tag("thinking")]],
|
|
20
|
+
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
|
21
|
+
]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .referencechunk import ReferenceChunk, ReferenceChunkTypedDict
|
|
5
|
+
from .textchunk import TextChunk, TextChunkTypedDict
|
|
6
|
+
from mistralai_gcp.types import BaseModel
|
|
7
|
+
from typing import List, Literal, Optional, Union
|
|
8
|
+
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
ThinkingTypedDict = TypeAliasType(
|
|
12
|
+
"ThinkingTypedDict", Union[ReferenceChunkTypedDict, TextChunkTypedDict]
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Thinking = TypeAliasType("Thinking", Union[ReferenceChunk, TextChunk])
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
ThinkChunkType = Literal["thinking",]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ThinkChunkTypedDict(TypedDict):
|
|
23
|
+
thinking: List[ThinkingTypedDict]
|
|
24
|
+
closed: NotRequired[bool]
|
|
25
|
+
r"""Whether the thinking chunk is closed or not. Currently only used for prefixing."""
|
|
26
|
+
type: NotRequired[ThinkChunkType]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class ThinkChunk(BaseModel):
|
|
30
|
+
thinking: List[Thinking]
|
|
31
|
+
|
|
32
|
+
closed: Optional[bool] = None
|
|
33
|
+
r"""Whether the thinking chunk is closed or not. Currently only used for prefixing."""
|
|
34
|
+
|
|
35
|
+
type: Optional[ThinkChunkType] = "thinking"
|
mistralai_gcp/models/tool.py
CHANGED
|
@@ -4,10 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
from .function import Function, FunctionTypedDict
|
|
5
5
|
from .tooltypes import ToolTypes
|
|
6
6
|
from mistralai_gcp.types import BaseModel
|
|
7
|
-
from mistralai_gcp.utils import validate_open_enum
|
|
8
|
-
from pydantic.functional_validators import PlainValidator
|
|
9
7
|
from typing import Optional
|
|
10
|
-
from typing_extensions import
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
class ToolTypedDict(TypedDict):
|
|
@@ -18,6 +16,4 @@ class ToolTypedDict(TypedDict):
|
|
|
18
16
|
class Tool(BaseModel):
|
|
19
17
|
function: Function
|
|
20
18
|
|
|
21
|
-
type:
|
|
22
|
-
None
|
|
23
|
-
)
|
|
19
|
+
type: Optional[ToolTypes] = None
|
mistralai_gcp/models/toolcall.py
CHANGED
|
@@ -4,10 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
from .functioncall import FunctionCall, FunctionCallTypedDict
|
|
5
5
|
from .tooltypes import ToolTypes
|
|
6
6
|
from mistralai_gcp.types import BaseModel
|
|
7
|
-
from mistralai_gcp.utils import validate_open_enum
|
|
8
|
-
from pydantic.functional_validators import PlainValidator
|
|
9
7
|
from typing import Optional
|
|
10
|
-
from typing_extensions import
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
class ToolCallTypedDict(TypedDict):
|
|
@@ -22,8 +20,6 @@ class ToolCall(BaseModel):
|
|
|
22
20
|
|
|
23
21
|
id: Optional[str] = "null"
|
|
24
22
|
|
|
25
|
-
type:
|
|
26
|
-
None
|
|
27
|
-
)
|
|
23
|
+
type: Optional[ToolTypes] = None
|
|
28
24
|
|
|
29
25
|
index: Optional[int] = 0
|
|
@@ -4,10 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
from .functionname import FunctionName, FunctionNameTypedDict
|
|
5
5
|
from .tooltypes import ToolTypes
|
|
6
6
|
from mistralai_gcp.types import BaseModel
|
|
7
|
-
from mistralai_gcp.utils import validate_open_enum
|
|
8
|
-
from pydantic.functional_validators import PlainValidator
|
|
9
7
|
from typing import Optional
|
|
10
|
-
from typing_extensions import
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
11
9
|
|
|
12
10
|
|
|
13
11
|
class ToolChoiceTypedDict(TypedDict):
|
|
@@ -24,6 +22,4 @@ class ToolChoice(BaseModel):
|
|
|
24
22
|
function: FunctionName
|
|
25
23
|
r"""this restriction of `Function` is used to select a specific function to call"""
|
|
26
24
|
|
|
27
|
-
type:
|
|
28
|
-
None
|
|
29
|
-
)
|
|
25
|
+
type: Optional[ToolTypes] = None
|
|
@@ -22,7 +22,7 @@ ToolMessageContentTypedDict = TypeAliasType(
|
|
|
22
22
|
ToolMessageContent = TypeAliasType("ToolMessageContent", Union[str, List[ContentChunk]])
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
ToolMessageRole = Literal["tool"]
|
|
25
|
+
ToolMessageRole = Literal["tool",]
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class ToolMessageTypedDict(TypedDict):
|
|
@@ -51,7 +51,7 @@ class ToolMessage(BaseModel):
|
|
|
51
51
|
|
|
52
52
|
m = {}
|
|
53
53
|
|
|
54
|
-
for n, f in self.model_fields.items():
|
|
54
|
+
for n, f in type(self).model_fields.items():
|
|
55
55
|
k = f.alias or n
|
|
56
56
|
val = serialized.get(k)
|
|
57
57
|
serialized.pop(k, None)
|
|
@@ -1,19 +1,82 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from mistralai_gcp.types import
|
|
5
|
-
|
|
4
|
+
from mistralai_gcp.types import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
Nullable,
|
|
7
|
+
OptionalNullable,
|
|
8
|
+
UNSET,
|
|
9
|
+
UNSET_SENTINEL,
|
|
10
|
+
)
|
|
11
|
+
import pydantic
|
|
12
|
+
from pydantic import ConfigDict, model_serializer
|
|
13
|
+
from typing import Any, Dict, Optional
|
|
14
|
+
from typing_extensions import NotRequired, TypedDict
|
|
6
15
|
|
|
7
16
|
|
|
8
17
|
class UsageInfoTypedDict(TypedDict):
|
|
9
|
-
prompt_tokens: int
|
|
10
|
-
completion_tokens: int
|
|
11
|
-
total_tokens: int
|
|
18
|
+
prompt_tokens: NotRequired[int]
|
|
19
|
+
completion_tokens: NotRequired[int]
|
|
20
|
+
total_tokens: NotRequired[int]
|
|
21
|
+
prompt_audio_seconds: NotRequired[Nullable[int]]
|
|
12
22
|
|
|
13
23
|
|
|
14
24
|
class UsageInfo(BaseModel):
|
|
15
|
-
|
|
25
|
+
model_config = ConfigDict(
|
|
26
|
+
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
|
|
27
|
+
)
|
|
28
|
+
__pydantic_extra__: Dict[str, Any] = pydantic.Field(init=False)
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
prompt_tokens: Optional[int] = 0
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
completion_tokens: Optional[int] = 0
|
|
33
|
+
|
|
34
|
+
total_tokens: Optional[int] = 0
|
|
35
|
+
|
|
36
|
+
prompt_audio_seconds: OptionalNullable[int] = UNSET
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def additional_properties(self):
|
|
40
|
+
return self.__pydantic_extra__
|
|
41
|
+
|
|
42
|
+
@additional_properties.setter
|
|
43
|
+
def additional_properties(self, value):
|
|
44
|
+
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
|
|
45
|
+
|
|
46
|
+
@model_serializer(mode="wrap")
|
|
47
|
+
def serialize_model(self, handler):
|
|
48
|
+
optional_fields = [
|
|
49
|
+
"prompt_tokens",
|
|
50
|
+
"completion_tokens",
|
|
51
|
+
"total_tokens",
|
|
52
|
+
"prompt_audio_seconds",
|
|
53
|
+
]
|
|
54
|
+
nullable_fields = ["prompt_audio_seconds"]
|
|
55
|
+
null_default_fields = []
|
|
56
|
+
|
|
57
|
+
serialized = handler(self)
|
|
58
|
+
|
|
59
|
+
m = {}
|
|
60
|
+
|
|
61
|
+
for n, f in type(self).model_fields.items():
|
|
62
|
+
k = f.alias or n
|
|
63
|
+
val = serialized.get(k)
|
|
64
|
+
serialized.pop(k, None)
|
|
65
|
+
|
|
66
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
67
|
+
is_set = (
|
|
68
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
69
|
+
or k in null_default_fields
|
|
70
|
+
) # pylint: disable=no-member
|
|
71
|
+
|
|
72
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
73
|
+
m[k] = val
|
|
74
|
+
elif val != UNSET_SENTINEL and (
|
|
75
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
76
|
+
):
|
|
77
|
+
m[k] = val
|
|
78
|
+
|
|
79
|
+
for k, v in serialized.items():
|
|
80
|
+
m[k] = v
|
|
81
|
+
|
|
82
|
+
return m
|
|
@@ -16,7 +16,7 @@ UserMessageContentTypedDict = TypeAliasType(
|
|
|
16
16
|
UserMessageContent = TypeAliasType("UserMessageContent", Union[str, List[ContentChunk]])
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
UserMessageRole = Literal["user"]
|
|
19
|
+
UserMessageRole = Literal["user",]
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class UserMessageTypedDict(TypedDict):
|
|
@@ -39,7 +39,7 @@ class UserMessage(BaseModel):
|
|
|
39
39
|
|
|
40
40
|
m = {}
|
|
41
41
|
|
|
42
|
-
for n, f in self.model_fields.items():
|
|
42
|
+
for n, f in type(self).model_fields.items():
|
|
43
43
|
k = f.alias or n
|
|
44
44
|
val = serialized.get(k)
|
|
45
45
|
serialized.pop(k, None)
|
mistralai_gcp/sdk.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
4
|
import weakref
|
|
5
|
-
from typing import Any, Optional, cast
|
|
5
|
+
from typing import Any, Optional, Union, cast
|
|
6
6
|
|
|
7
7
|
import google.auth
|
|
8
8
|
import google.auth.credentials
|
|
@@ -67,30 +67,32 @@ class MistralGoogleCloud(BaseSDK):
|
|
|
67
67
|
:param timeout_ms: Optional request timeout applied to each operation in milliseconds
|
|
68
68
|
"""
|
|
69
69
|
|
|
70
|
+
credentials = None
|
|
70
71
|
if not access_token:
|
|
71
72
|
credentials, loaded_project_id = google.auth.default(
|
|
72
73
|
scopes=["https://www.googleapis.com/auth/cloud-platform"],
|
|
73
74
|
)
|
|
74
|
-
credentials.refresh(google.auth.transport.requests.Request())
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
# default will already raise a google.auth.exceptions.DefaultCredentialsError if no credentials are found
|
|
77
|
+
assert isinstance(
|
|
78
|
+
credentials, google.auth.credentials.Credentials
|
|
79
|
+
), "credentials must be an instance of google.auth.credentials.Credentials"
|
|
80
80
|
|
|
81
|
+
credentials.refresh(google.auth.transport.requests.Request())
|
|
81
82
|
project_id = project_id or loaded_project_id
|
|
82
83
|
|
|
83
84
|
if project_id is None:
|
|
84
|
-
raise
|
|
85
|
+
raise ValueError("project_id must be provided")
|
|
85
86
|
|
|
86
87
|
def auth_token() -> str:
|
|
87
88
|
if access_token:
|
|
88
89
|
return access_token
|
|
89
90
|
|
|
91
|
+
assert credentials is not None, "credentials must be initialized"
|
|
90
92
|
credentials.refresh(google.auth.transport.requests.Request())
|
|
91
93
|
token = credentials.token
|
|
92
94
|
if not token:
|
|
93
|
-
raise
|
|
95
|
+
raise Exception("Failed to get token from credentials")
|
|
94
96
|
return token
|
|
95
97
|
|
|
96
98
|
client_supplied = True
|
|
@@ -197,7 +199,7 @@ class GoogleCloudBeforeRequestHook(BeforeRequestHook):
|
|
|
197
199
|
|
|
198
200
|
def before_request(
|
|
199
201
|
self, hook_ctx, request: httpx.Request
|
|
200
|
-
) -> httpx.Request
|
|
202
|
+
) -> Union[httpx.Request, Exception]:
|
|
201
203
|
# The goal of this function is to template in the region, project and model into the URL path
|
|
202
204
|
# We do this here so that the API remains more user-friendly
|
|
203
205
|
model_id = None
|
|
@@ -210,7 +212,7 @@ class GoogleCloudBeforeRequestHook(BeforeRequestHook):
|
|
|
210
212
|
new_content = json.dumps(parsed).encode("utf-8")
|
|
211
213
|
|
|
212
214
|
if model_id == "":
|
|
213
|
-
raise
|
|
215
|
+
raise ValueError("model must be provided")
|
|
214
216
|
|
|
215
217
|
stream = "streamRawPredict" in request.url.path
|
|
216
218
|
specifier = "streamRawPredict" if stream else "rawPredict"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
-
from ._hooks import SDKHooks
|
|
4
3
|
from ._version import (
|
|
5
4
|
__gen_version__,
|
|
6
5
|
__openapi_doc_version__,
|
|
@@ -42,9 +41,6 @@ class SDKConfiguration:
|
|
|
42
41
|
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
|
43
42
|
timeout_ms: Optional[int] = None
|
|
44
43
|
|
|
45
|
-
def __post_init__(self):
|
|
46
|
-
self._hooks = SDKHooks()
|
|
47
|
-
|
|
48
44
|
def get_server_details(self) -> Tuple[str, Dict[str, str]]:
|
|
49
45
|
if self.server_url is not None and self.server_url:
|
|
50
46
|
return remove_suffix(self.server_url, "/"), {}
|
|
@@ -55,6 +51,3 @@ class SDKConfiguration:
|
|
|
55
51
|
raise ValueError(f'Invalid server "{self.server}"')
|
|
56
52
|
|
|
57
53
|
return SERVERS[self.server], {}
|
|
58
|
-
|
|
59
|
-
def get_hooks(self) -> SDKHooks:
|
|
60
|
-
return self._hooks
|
mistralai_gcp/types/basemodel.py
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from pydantic import ConfigDict, model_serializer
|
|
4
4
|
from pydantic import BaseModel as PydanticBaseModel
|
|
5
|
-
from
|
|
5
|
+
from pydantic_core import core_schema
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Literal, Optional, TypeVar, Union
|
|
6
7
|
from typing_extensions import TypeAliasType, TypeAlias
|
|
7
8
|
|
|
8
9
|
|
|
@@ -35,5 +36,42 @@ else:
|
|
|
35
36
|
"OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
|
|
36
37
|
)
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
UnrecognizedStr
|
|
39
|
+
|
|
40
|
+
class UnrecognizedStr(str):
|
|
41
|
+
@classmethod
|
|
42
|
+
def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
|
|
43
|
+
# Make UnrecognizedStr only work in lax mode, not strict mode
|
|
44
|
+
# This makes it a "fallback" option when more specific types (like Literals) don't match
|
|
45
|
+
def validate_lax(v: Any) -> 'UnrecognizedStr':
|
|
46
|
+
if isinstance(v, cls):
|
|
47
|
+
return v
|
|
48
|
+
return cls(str(v))
|
|
49
|
+
|
|
50
|
+
# Use lax_or_strict_schema where strict always fails
|
|
51
|
+
# This forces Pydantic to prefer other union members in strict mode
|
|
52
|
+
# and only fall back to UnrecognizedStr in lax mode
|
|
53
|
+
return core_schema.lax_or_strict_schema(
|
|
54
|
+
lax_schema=core_schema.chain_schema([
|
|
55
|
+
core_schema.str_schema(),
|
|
56
|
+
core_schema.no_info_plain_validator_function(validate_lax)
|
|
57
|
+
]),
|
|
58
|
+
strict_schema=core_schema.none_schema(), # Always fails in strict mode
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class UnrecognizedInt(int):
|
|
63
|
+
@classmethod
|
|
64
|
+
def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
|
|
65
|
+
# Make UnrecognizedInt only work in lax mode, not strict mode
|
|
66
|
+
# This makes it a "fallback" option when more specific types (like Literals) don't match
|
|
67
|
+
def validate_lax(v: Any) -> 'UnrecognizedInt':
|
|
68
|
+
if isinstance(v, cls):
|
|
69
|
+
return v
|
|
70
|
+
return cls(int(v))
|
|
71
|
+
return core_schema.lax_or_strict_schema(
|
|
72
|
+
lax_schema=core_schema.chain_schema([
|
|
73
|
+
core_schema.int_schema(),
|
|
74
|
+
core_schema.no_info_plain_validator_function(validate_lax)
|
|
75
|
+
]),
|
|
76
|
+
strict_schema=core_schema.none_schema(), # Always fails in strict mode
|
|
77
|
+
)
|
mistralai_gcp/utils/__init__.py
CHANGED
|
@@ -1,50 +1,56 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
import builtins
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
if TYPE_CHECKING:
|
|
9
|
+
from .annotations import get_discriminator
|
|
10
|
+
from .datetimes import parse_datetime
|
|
11
|
+
from .enums import OpenEnumMeta
|
|
12
|
+
from .headers import get_headers, get_response_headers
|
|
13
|
+
from .metadata import (
|
|
14
|
+
FieldMetadata,
|
|
15
|
+
find_metadata,
|
|
16
|
+
FormMetadata,
|
|
17
|
+
HeaderMetadata,
|
|
18
|
+
MultipartFormMetadata,
|
|
19
|
+
PathParamMetadata,
|
|
20
|
+
QueryParamMetadata,
|
|
21
|
+
RequestMetadata,
|
|
22
|
+
SecurityMetadata,
|
|
23
|
+
)
|
|
24
|
+
from .queryparams import get_query_params
|
|
25
|
+
from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig
|
|
26
|
+
from .requestbodies import serialize_request_body, SerializedRequestBody
|
|
27
|
+
from .security import get_security
|
|
28
|
+
from .serializers import (
|
|
29
|
+
get_pydantic_model,
|
|
30
|
+
marshal_json,
|
|
31
|
+
unmarshal,
|
|
32
|
+
unmarshal_json,
|
|
33
|
+
serialize_decimal,
|
|
34
|
+
serialize_float,
|
|
35
|
+
serialize_int,
|
|
36
|
+
stream_to_text,
|
|
37
|
+
stream_to_text_async,
|
|
38
|
+
stream_to_bytes,
|
|
39
|
+
stream_to_bytes_async,
|
|
40
|
+
validate_const,
|
|
41
|
+
validate_decimal,
|
|
42
|
+
validate_float,
|
|
43
|
+
validate_int,
|
|
44
|
+
)
|
|
45
|
+
from .url import generate_url, template_url, remove_suffix
|
|
46
|
+
from .values import (
|
|
47
|
+
get_global_from_env,
|
|
48
|
+
match_content_type,
|
|
49
|
+
match_status_codes,
|
|
50
|
+
match_response,
|
|
51
|
+
cast_partial,
|
|
52
|
+
)
|
|
53
|
+
from .logger import Logger, get_body_content, get_default_logger
|
|
48
54
|
|
|
49
55
|
__all__ = [
|
|
50
56
|
"BackoffStrategy",
|
|
@@ -55,6 +61,7 @@ __all__ = [
|
|
|
55
61
|
"get_body_content",
|
|
56
62
|
"get_default_logger",
|
|
57
63
|
"get_discriminator",
|
|
64
|
+
"parse_datetime",
|
|
58
65
|
"get_global_from_env",
|
|
59
66
|
"get_headers",
|
|
60
67
|
"get_pydantic_model",
|
|
@@ -94,6 +101,94 @@ __all__ = [
|
|
|
94
101
|
"validate_const",
|
|
95
102
|
"validate_float",
|
|
96
103
|
"validate_int",
|
|
97
|
-
"validate_open_enum",
|
|
98
104
|
"cast_partial",
|
|
99
105
|
]
|
|
106
|
+
|
|
107
|
+
_dynamic_imports: dict[str, str] = {
|
|
108
|
+
"BackoffStrategy": ".retries",
|
|
109
|
+
"FieldMetadata": ".metadata",
|
|
110
|
+
"find_metadata": ".metadata",
|
|
111
|
+
"FormMetadata": ".metadata",
|
|
112
|
+
"generate_url": ".url",
|
|
113
|
+
"get_body_content": ".logger",
|
|
114
|
+
"get_default_logger": ".logger",
|
|
115
|
+
"get_discriminator": ".annotations",
|
|
116
|
+
"parse_datetime": ".datetimes",
|
|
117
|
+
"get_global_from_env": ".values",
|
|
118
|
+
"get_headers": ".headers",
|
|
119
|
+
"get_pydantic_model": ".serializers",
|
|
120
|
+
"get_query_params": ".queryparams",
|
|
121
|
+
"get_response_headers": ".headers",
|
|
122
|
+
"get_security": ".security",
|
|
123
|
+
"HeaderMetadata": ".metadata",
|
|
124
|
+
"Logger": ".logger",
|
|
125
|
+
"marshal_json": ".serializers",
|
|
126
|
+
"match_content_type": ".values",
|
|
127
|
+
"match_status_codes": ".values",
|
|
128
|
+
"match_response": ".values",
|
|
129
|
+
"MultipartFormMetadata": ".metadata",
|
|
130
|
+
"OpenEnumMeta": ".enums",
|
|
131
|
+
"PathParamMetadata": ".metadata",
|
|
132
|
+
"QueryParamMetadata": ".metadata",
|
|
133
|
+
"remove_suffix": ".url",
|
|
134
|
+
"Retries": ".retries",
|
|
135
|
+
"retry": ".retries",
|
|
136
|
+
"retry_async": ".retries",
|
|
137
|
+
"RetryConfig": ".retries",
|
|
138
|
+
"RequestMetadata": ".metadata",
|
|
139
|
+
"SecurityMetadata": ".metadata",
|
|
140
|
+
"serialize_decimal": ".serializers",
|
|
141
|
+
"serialize_float": ".serializers",
|
|
142
|
+
"serialize_int": ".serializers",
|
|
143
|
+
"serialize_request_body": ".requestbodies",
|
|
144
|
+
"SerializedRequestBody": ".requestbodies",
|
|
145
|
+
"stream_to_text": ".serializers",
|
|
146
|
+
"stream_to_text_async": ".serializers",
|
|
147
|
+
"stream_to_bytes": ".serializers",
|
|
148
|
+
"stream_to_bytes_async": ".serializers",
|
|
149
|
+
"template_url": ".url",
|
|
150
|
+
"unmarshal": ".serializers",
|
|
151
|
+
"unmarshal_json": ".serializers",
|
|
152
|
+
"validate_decimal": ".serializers",
|
|
153
|
+
"validate_const": ".serializers",
|
|
154
|
+
"validate_float": ".serializers",
|
|
155
|
+
"validate_int": ".serializers",
|
|
156
|
+
"cast_partial": ".values",
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def dynamic_import(modname, retries=3):
|
|
161
|
+
for attempt in range(retries):
|
|
162
|
+
try:
|
|
163
|
+
return import_module(modname, __package__)
|
|
164
|
+
except KeyError:
|
|
165
|
+
# Clear any half-initialized module and retry
|
|
166
|
+
sys.modules.pop(modname, None)
|
|
167
|
+
if attempt == retries - 1:
|
|
168
|
+
break
|
|
169
|
+
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def __getattr__(attr_name: str) -> object:
|
|
173
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
174
|
+
if module_name is None:
|
|
175
|
+
raise AttributeError(
|
|
176
|
+
f"no {attr_name} found in _dynamic_imports, module name -> {__name__} "
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
try:
|
|
180
|
+
module = dynamic_import(module_name)
|
|
181
|
+
return getattr(module, attr_name)
|
|
182
|
+
except ImportError as e:
|
|
183
|
+
raise ImportError(
|
|
184
|
+
f"Failed to import {attr_name} from {module_name}: {e}"
|
|
185
|
+
) from e
|
|
186
|
+
except AttributeError as e:
|
|
187
|
+
raise AttributeError(
|
|
188
|
+
f"Failed to get {attr_name} from {module_name}: {e}"
|
|
189
|
+
) from e
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def __dir__():
|
|
193
|
+
lazy_attrs = builtins.list(_dynamic_imports.keys())
|
|
194
|
+
return builtins.sorted(lazy_attrs)
|