mistralai 1.9.8__py3-none-any.whl → 1.9.10__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/_version.py CHANGED
@@ -3,10 +3,10 @@
3
3
  import importlib.metadata
4
4
 
5
5
  __title__: str = "mistralai"
6
- __version__: str = "1.9.8"
6
+ __version__: str = "1.9.10"
7
7
  __openapi_doc_version__: str = "1.0.0"
8
8
  __gen_version__: str = "2.634.2"
9
- __user_agent__: str = "speakeasy-sdk/python 1.9.8 2.634.2 1.0.0 mistralai"
9
+ __user_agent__: str = "speakeasy-sdk/python 1.9.10 2.634.2 1.0.0 mistralai"
10
10
 
11
11
  try:
12
12
  if __package__ is not None:
mistralai/embeddings.py CHANGED
@@ -20,6 +20,7 @@ class Embeddings(BaseSDK):
20
20
  ],
21
21
  output_dimension: OptionalNullable[int] = UNSET,
22
22
  output_dtype: Optional[models.EmbeddingDtype] = None,
23
+ encoding_format: Optional[models.EncodingFormat] = None,
23
24
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
24
25
  server_url: Optional[str] = None,
25
26
  timeout_ms: Optional[int] = None,
@@ -33,6 +34,7 @@ class Embeddings(BaseSDK):
33
34
  :param inputs: Text to embed.
34
35
  :param output_dimension: The dimension of the output embeddings.
35
36
  :param output_dtype:
37
+ :param encoding_format:
36
38
  :param retries: Override the default retry configuration for this method
37
39
  :param server_url: Override the default server URL for this method
38
40
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -53,6 +55,7 @@ class Embeddings(BaseSDK):
53
55
  inputs=inputs,
54
56
  output_dimension=output_dimension,
55
57
  output_dtype=output_dtype,
58
+ encoding_format=encoding_format,
56
59
  )
57
60
 
58
61
  req = self._build_request(
@@ -134,6 +137,7 @@ class Embeddings(BaseSDK):
134
137
  ],
135
138
  output_dimension: OptionalNullable[int] = UNSET,
136
139
  output_dtype: Optional[models.EmbeddingDtype] = None,
140
+ encoding_format: Optional[models.EncodingFormat] = None,
137
141
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
138
142
  server_url: Optional[str] = None,
139
143
  timeout_ms: Optional[int] = None,
@@ -147,6 +151,7 @@ class Embeddings(BaseSDK):
147
151
  :param inputs: Text to embed.
148
152
  :param output_dimension: The dimension of the output embeddings.
149
153
  :param output_dtype:
154
+ :param encoding_format:
150
155
  :param retries: Override the default retry configuration for this method
151
156
  :param server_url: Override the default server URL for this method
152
157
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -167,6 +172,7 @@ class Embeddings(BaseSDK):
167
172
  inputs=inputs,
168
173
  output_dimension=output_dimension,
169
174
  output_dtype=output_dtype,
175
+ encoding_format=encoding_format,
170
176
  )
171
177
 
172
178
  req = self._build_request_async(
@@ -389,6 +389,7 @@ if TYPE_CHECKING:
389
389
  EmbeddingResponseData,
390
390
  EmbeddingResponseDataTypedDict,
391
391
  )
392
+ from .encodingformat import EncodingFormat
392
393
  from .entitytype import EntityType
393
394
  from .eventout import EventOut, EventOutTypedDict
394
395
  from .file import File, FileTypedDict
@@ -767,6 +768,10 @@ if TYPE_CHECKING:
767
768
  SystemMessageContentTypedDict,
768
769
  SystemMessageTypedDict,
769
770
  )
771
+ from .systemmessagecontentchunks import (
772
+ SystemMessageContentChunks,
773
+ SystemMessageContentChunksTypedDict,
774
+ )
770
775
  from .textchunk import TextChunk, TextChunkType, TextChunkTypedDict
771
776
  from .thinkchunk import (
772
777
  ThinkChunk,
@@ -1156,6 +1161,7 @@ __all__ = [
1156
1161
  "EmbeddingResponseData",
1157
1162
  "EmbeddingResponseDataTypedDict",
1158
1163
  "EmbeddingResponseTypedDict",
1164
+ "EncodingFormat",
1159
1165
  "EntityType",
1160
1166
  "Entries",
1161
1167
  "EntriesTypedDict",
@@ -1472,6 +1478,8 @@ __all__ = [
1472
1478
  "StopTypedDict",
1473
1479
  "SystemMessage",
1474
1480
  "SystemMessageContent",
1481
+ "SystemMessageContentChunks",
1482
+ "SystemMessageContentChunksTypedDict",
1475
1483
  "SystemMessageContentTypedDict",
1476
1484
  "SystemMessageTypedDict",
1477
1485
  "TextChunk",
@@ -1858,6 +1866,7 @@ _dynamic_imports: dict[str, str] = {
1858
1866
  "EmbeddingResponseTypedDict": ".embeddingresponse",
1859
1867
  "EmbeddingResponseData": ".embeddingresponsedata",
1860
1868
  "EmbeddingResponseDataTypedDict": ".embeddingresponsedata",
1869
+ "EncodingFormat": ".encodingformat",
1861
1870
  "EntityType": ".entitytype",
1862
1871
  "EventOut": ".eventout",
1863
1872
  "EventOutTypedDict": ".eventout",
@@ -2159,6 +2168,8 @@ _dynamic_imports: dict[str, str] = {
2159
2168
  "SystemMessageContent": ".systemmessage",
2160
2169
  "SystemMessageContentTypedDict": ".systemmessage",
2161
2170
  "SystemMessageTypedDict": ".systemmessage",
2171
+ "SystemMessageContentChunks": ".systemmessagecontentchunks",
2172
+ "SystemMessageContentChunksTypedDict": ".systemmessagecontentchunks",
2162
2173
  "TextChunk": ".textchunk",
2163
2174
  "TextChunkType": ".textchunk",
2164
2175
  "TextChunkTypedDict": ".textchunk",
@@ -12,6 +12,11 @@ APIEndpoint = Union[
12
12
  "/v1/fim/completions",
13
13
  "/v1/moderations",
14
14
  "/v1/chat/moderations",
15
+ "/v1/ocr",
16
+ "/v1/classifications",
17
+ "/v1/chat/classifications",
18
+ "/v1/conversations",
19
+ "/v1/audio/transcriptions",
15
20
  ],
16
21
  UnrecognizedStr,
17
22
  ]
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .embeddingdtype import EmbeddingDtype
5
+ from .encodingformat import EncodingFormat
5
6
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
7
  import pydantic
7
8
  from pydantic import model_serializer
@@ -27,6 +28,7 @@ class EmbeddingRequestTypedDict(TypedDict):
27
28
  output_dimension: NotRequired[Nullable[int]]
28
29
  r"""The dimension of the output embeddings."""
29
30
  output_dtype: NotRequired[EmbeddingDtype]
31
+ encoding_format: NotRequired[EncodingFormat]
30
32
 
31
33
 
32
34
  class EmbeddingRequest(BaseModel):
@@ -41,9 +43,11 @@ class EmbeddingRequest(BaseModel):
41
43
 
42
44
  output_dtype: Optional[EmbeddingDtype] = None
43
45
 
46
+ encoding_format: Optional[EncodingFormat] = None
47
+
44
48
  @model_serializer(mode="wrap")
45
49
  def serialize_model(self, handler):
46
- optional_fields = ["output_dimension", "output_dtype"]
50
+ optional_fields = ["output_dimension", "output_dtype", "encoding_format"]
47
51
  nullable_fields = ["output_dimension"]
48
52
  null_default_fields = []
49
53
 
@@ -0,0 +1,7 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from typing import Literal
5
+
6
+
7
+ EncodingFormat = Literal["float", "base64"]
@@ -1,19 +1,23 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from .textchunk import TextChunk, TextChunkTypedDict
4
+ from .systemmessagecontentchunks import (
5
+ SystemMessageContentChunks,
6
+ SystemMessageContentChunksTypedDict,
7
+ )
5
8
  from mistralai.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", Union[str, List[TextChunkTypedDict]]
14
+ "SystemMessageContentTypedDict",
15
+ Union[str, List[SystemMessageContentChunksTypedDict]],
12
16
  )
13
17
 
14
18
 
15
19
  SystemMessageContent = TypeAliasType(
16
- "SystemMessageContent", Union[str, List[TextChunk]]
20
+ "SystemMessageContent", Union[str, List[SystemMessageContentChunks]]
17
21
  )
18
22
 
19
23
 
@@ -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.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
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mistralai
3
- Version: 1.9.8
3
+ Version: 1.9.10
4
4
  Summary: Python Client SDK for the Mistral AI API.
5
5
  Author: Mistral
6
6
  Requires-Python: >=3.9
@@ -54,7 +54,7 @@ mistralai_azure/models/usermessage.py,sha256=tzTfEH0wzDHf96C8AJanTxckrDJOpxtMOa3
54
54
  mistralai_azure/models/validationerror.py,sha256=vghbUqW9H5AsbYmW5i0C56eHPFC054x8SJA-mJZPKak,532
55
55
  mistralai_azure/ocr.py,sha256=hHX6-72A_nSRt8aPOaBf5DPP9NVKdqddRkkWObK8KeM,11911
56
56
  mistralai_azure/py.typed,sha256=zrp19r0G21lr2yRiMC0f8MFkQFGj9wMpSbboePMg8KM,59
57
- mistralai_azure/sdk.py,sha256=CVTTW027gX8y4rhprAbmkB5W7r3afru01yRSPwxpMk4,5437
57
+ mistralai_azure/sdk.py,sha256=JByPLw6kJhZi2npJvki87fd3b2Z4E-dAA6eshZ19BOI,6667
58
58
  mistralai_azure/sdkconfiguration.py,sha256=tqLLVewof7YZcBIykjMjGZIEtX_b_JKaMP9KHNdrRsM,1728
59
59
  mistralai_azure/types/__init__.py,sha256=RArOwSgeeTIva6h-4ttjXwMUeCkz10nAFBL9D-QljI4,377
60
60
  mistralai_azure/types/basemodel.py,sha256=L79WXvTECbSqaJzs8D3ud_KdIWkU7Cx2wbohDAktE9E,1127
@@ -150,7 +150,7 @@ mistralai/_hooks/deprecation_warning.py,sha256=eyEOf7-o9uqqNWJnufD2RXp3dYrGV4in9
150
150
  mistralai/_hooks/registration.py,sha256=ML0W-XbE4WYdJ4eGks_XxF2aLCJTaIWjQATFGzFwvyU,861
151
151
  mistralai/_hooks/sdkhooks.py,sha256=s-orhdvnV89TmI3QiPC2LWQtYeM9RrsG1CTll-fYZmQ,2559
152
152
  mistralai/_hooks/types.py,sha256=70IiFr5bfsJYafuDkXQWVfl6nY4dQkA5SZoEBCircqs,3047
153
- mistralai/_version.py,sha256=6FjB8zY1tFIrap8yREauj7OwtQdW0EpeYdqcdGIlUwA,460
153
+ mistralai/_version.py,sha256=LEQalhqj3K9_phhNqDx2o8HDpgflVQxEcns-7vQGtB8,462
154
154
  mistralai/accesses.py,sha256=o5VCW-nyOfwzopHo0jSXrPKJ1fqJL88PZto1RwysXPA,27320
155
155
  mistralai/agents.py,sha256=3E-c1YZOp3mS1PqA6OYekZmOcAdLCqWfq1o-hqUMsIw,33960
156
156
  mistralai/async_client.py,sha256=KUdYxIIqoD6L7vB0EGwUR6lQ0NK5iCTHjnLVR9CVcJY,355
@@ -163,7 +163,7 @@ mistralai/classifiers.py,sha256=EsAvZi0dxM4qDw8xl84h6kZBWm4zdiP-f0eslqvDxAo,3415
163
163
  mistralai/client.py,sha256=hrPg-LciKMKiascF0WbRRmqQyCv1lb2yDh6j-aaKVNo,509
164
164
  mistralai/conversations.py,sha256=TXssMV9qjYRSTk90IVXPrzh-N1-pwb9sjKz3-48lRsw,110878
165
165
  mistralai/documents.py,sha256=yh7BNimMrNa6XmiF3-ym5VqAuPneKtMXS2fKN5PP8BY,85763
166
- mistralai/embeddings.py,sha256=L0jk6bXAc3FUYv0Rqk6CPXXabqhwfYG1OXLMlaille8,9352
166
+ mistralai/embeddings.py,sha256=M4XS5GclIGRYHMNH0sSIro5KmB2g7d0DMATi8im2gHc,9636
167
167
  mistralai/extra/README.md,sha256=BTS9fy0ijkiUP7ZVoFQ7FVBxHtXIXqucYZyy_ucFjo4,1739
168
168
  mistralai/extra/__init__.py,sha256=8DsU_omYYadqcwlmBOoakBwkWKcSohwLmtB8v-jkn2M,392
169
169
  mistralai/extra/exceptions.py,sha256=4EEygCfdsniYiroHEFVSVDqerQZkpRG027mlJXvMqns,428
@@ -192,7 +192,7 @@ mistralai/jobs.py,sha256=BUeEMx-SR3QrB8tyjjDndtcCTF-cs3640I38AWYW18w,47237
192
192
  mistralai/libraries.py,sha256=C7TqHmnFR3j4yGaEulGRu2Xdp9tW9Pj-FSZZG9fBn9g,41070
193
193
  mistralai/mistral_agents.py,sha256=6osNLzBNN9IFRhpeNzt6VGpqHlCo_6HnmMBvxzqd3F4,46043
194
194
  mistralai/mistral_jobs.py,sha256=LlN0-ro8mMqgRRDtUHxwfA76IjDmScQ9rT1gb6Qu91I,31962
195
- mistralai/models/__init__.py,sha256=I2RwD4xCeJ2UkF1TLJ4iLHpxJRc3rBsvZtEf0-anbOA,96959
195
+ mistralai/models/__init__.py,sha256=E3Yv-bm4lLG4AEZDA8u8AypEaOJtSI-XqbGj7VPIVZg,97418
196
196
  mistralai/models/agent.py,sha256=kM3lPW08V5B3CfBuIFZrEYAyClECj0Ial7-cQztfGmA,4191
197
197
  mistralai/models/agentconversation.py,sha256=-vqTZ116MNx4JRs9N6cabsGXn4tILg_JP3JcL-iJpK0,2092
198
198
  mistralai/models/agentcreationrequest.py,sha256=VdCCQEnBVfZU2m1EtRy5vEm_zsPIGPGLF21TXKjOm7E,3958
@@ -214,7 +214,7 @@ mistralai/models/agents_api_v1_conversations_restartop.py,sha256=pjsbjzKTeWgSBiv
214
214
  mistralai/models/agentscompletionrequest.py,sha256=9eQ3v_F4pIOFP0d2mph27_3PS45a0UvQzDSFO88EhAk,8589
215
215
  mistralai/models/agentscompletionstreamrequest.py,sha256=hTypANJ-SHYTpWt7wWzQWCHuvcnahZoGdDJ1COQsdys,8034
216
216
  mistralai/models/agentupdaterequest.py,sha256=uoqwrx1KypzBrRNYECuoD_Z6r0ahsxqDiPvhuqnaH4E,4100
217
- mistralai/models/apiendpoint.py,sha256=Hvar5leWsJR_FYb0UzRlSw3vRdBZhk_6BR5r2pIb214,400
217
+ mistralai/models/apiendpoint.py,sha256=e-d_e8Z7indj9QtiDZtYU3m7OQTvzRw-cCk3Ag_gbEo,551
218
218
  mistralai/models/archiveftmodelout.py,sha256=VdppiqIB9JGNB2B0-Y6XQfQgDmB-hOa1Bta3v_StbLs,565
219
219
  mistralai/models/assistantmessage.py,sha256=3qbCraZpjX_clXjT1wgOBeQuQBjX22XLQMIlR3v5fZw,2630
220
220
  mistralai/models/audiochunk.py,sha256=npAWiX43d_fZ-8Bnnm_z-p7bcwpAhKyYidy_VIJcrxs,481
@@ -278,9 +278,10 @@ mistralai/models/documenttextcontent.py,sha256=uQKQu3H31Oo8HgAt7qDYMX4CByAPY71lh
278
278
  mistralai/models/documentupdatein.py,sha256=ql6Exax-hZMIVdS9tbtzWX0YIJ_mSqwSUV56al2laOE,1352
279
279
  mistralai/models/documenturlchunk.py,sha256=yiqte4P63DCyDKDIYKD0pP9S4HjFNXHCXob4nnzY6nY,1710
280
280
  mistralai/models/embeddingdtype.py,sha256=c7L-PKhBgPVPZeMGuMub0ZOs0MdxMbpW2ebE0t7oEpU,209
281
- mistralai/models/embeddingrequest.py,sha256=G-JirOJnoE8qUCorqbRSUAjeG8db5LPFPsIf8RuBdKE,2264
281
+ mistralai/models/embeddingrequest.py,sha256=akcstmiH5e21xKqAzXSid4HzFeUMVA28vRhJpHKROSg,2429
282
282
  mistralai/models/embeddingresponse.py,sha256=te6E_LYEzRjHJ9QREmsFp5PeNP2J_8ALVjyb1T20pNA,663
283
283
  mistralai/models/embeddingresponsedata.py,sha256=fJ3mrZqyBBBE40a6iegOJX3DVDfgyMRq23ByeGSTLFk,534
284
+ mistralai/models/encodingformat.py,sha256=pH02s992pVskofo56idSek4sAn3MD6Iu7IAyCGmeJ-U,181
284
285
  mistralai/models/entitytype.py,sha256=tyqYYy74ygqwapkV-KFllGcgW7SYrU1ROjQ1CJbOZsM,313
285
286
  mistralai/models/eventout.py,sha256=UMqHEJMMJH68gbPA7uKF8bnPZmVzKSa-fXibFyXqTOg,1639
286
287
  mistralai/models/file.py,sha256=QJ3IkP4t_ZssCivHzIPp-4co_rIY16Usg2dLrVb5kz0,956
@@ -397,7 +398,8 @@ mistralai/models/sharingin.py,sha256=0TWKw7Fb3dPjBH-kBvZWV62TFlOoFGxkO3d7B9Z01zo
397
398
  mistralai/models/sharingout.py,sha256=9bxela_QJXxLD37ba8siYMidyqEpp-2a9sVFvabr3PU,1557
398
399
  mistralai/models/source.py,sha256=_MSV-LRL2fL7wCUTXEvvsOUIWlOKqPvdZS4rm2Xhs0o,264
399
400
  mistralai/models/ssetypes.py,sha256=xJlN3JFQ-EaF90nkD88zwjSSsgRN1C59JPZ97K1kASc,531
400
- mistralai/models/systemmessage.py,sha256=ZTDim1ZLHLiCe2zd70PuxcGyUrNhB_aFSMOpOzl5eCI,786
401
+ mistralai/models/systemmessage.py,sha256=-yWm6HzcVh34YOTop1z3l92IvgNwcWMMENFD8bCgMLk,889
402
+ mistralai/models/systemmessagecontentchunks.py,sha256=zO5Hfr7u5E-DDsH1lPVmUg88pI3ZOjpXBDAwnea-RHk,732
401
403
  mistralai/models/textchunk.py,sha256=2VD-TR3NOOWJ9Jzcw_E3ryq0GWz6b5XSP3k5o7oVlnc,448
402
404
  mistralai/models/thinkchunk.py,sha256=HpD23LlAzITRtTQI2naWYp4nDDSnzV7U97QoXSby2Fg,1084
403
405
  mistralai/models/timestampgranularity.py,sha256=UxTv5VJwJ2bkp1cD9kWPptVC8zqUSOa3hb7NatzydH0,179
@@ -456,7 +458,7 @@ mistralai/utils/security.py,sha256=vWlpkikOnGN_HRRhJ7Pb8ywVAjiM3d3ey3oTWtM6jTU,6
456
458
  mistralai/utils/serializers.py,sha256=hiHBXM1AY8_N2Z_rvFfNSYwvLBkSQlPGFp8poasdU4s,5986
457
459
  mistralai/utils/url.py,sha256=BgGPgcTA6MRK4bF8fjP2dUopN3NzEzxWMXPBVg8NQUA,5254
458
460
  mistralai/utils/values.py,sha256=CcaCXEa3xHhkUDROyXZocN8f0bdITftv9Y0P9lTf0YM,3517
459
- mistralai-1.9.8.dist-info/LICENSE,sha256=rUtQ_9GD0OyLPlb-2uWVdfE87hzudMRmsW-tS-0DK-0,11340
460
- mistralai-1.9.8.dist-info/METADATA,sha256=1Dbq0gOz5mYZMZq-iWpXAabW8wXQ04G8GrRQe1Il8Oc,37249
461
- mistralai-1.9.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
462
- mistralai-1.9.8.dist-info/RECORD,,
461
+ mistralai-1.9.10.dist-info/LICENSE,sha256=rUtQ_9GD0OyLPlb-2uWVdfE87hzudMRmsW-tS-0DK-0,11340
462
+ mistralai-1.9.10.dist-info/METADATA,sha256=DJmhK8c34yXgOFqLTic-fhf1m9PxL3jP2hvfOjNcUDk,37250
463
+ mistralai-1.9.10.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
464
+ mistralai-1.9.10.dist-info/RECORD,,
mistralai_azure/sdk.py CHANGED
@@ -1,27 +1,33 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
- import weakref
4
- from typing import Any, Callable, Dict, Optional, Union, cast
5
-
6
- import httpx
7
-
8
- from mistralai_azure import models, utils
9
- from mistralai_azure._hooks import SDKHooks
10
- from mistralai_azure.chat import Chat
11
- from mistralai_azure.types import UNSET, OptionalNullable
12
-
13
3
  from .basesdk import BaseSDK
14
4
  from .httpclient import AsyncHttpClient, ClientOwner, HttpClient, close_clients
15
5
  from .sdkconfiguration import SDKConfiguration
16
6
  from .utils.logger import Logger, get_default_logger
17
7
  from .utils.retries import RetryConfig
8
+ import httpx
9
+ import importlib
10
+ from mistralai_azure import models, utils
11
+ from mistralai_azure._hooks import SDKHooks
12
+ from mistralai_azure.types import OptionalNullable, UNSET
13
+ from typing import Any, Callable, Dict, Optional, TYPE_CHECKING, Union, cast
14
+ import weakref
15
+
16
+ if TYPE_CHECKING:
17
+ from mistralai_azure.chat import Chat
18
+ from mistralai_azure.ocr import Ocr
18
19
 
19
20
 
20
21
  class MistralAzure(BaseSDK):
21
22
  r"""Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create your account on [La Plateforme](https://console.mistral.ai) to get access and read the [docs](https://docs.mistral.ai) to learn how to use it."""
22
23
 
23
- chat: Chat
24
+ chat: "Chat"
24
25
  r"""Chat Completion API."""
26
+ ocr: "Ocr"
27
+ _sub_sdk_map = {
28
+ "chat": ("mistralai_azure.chat", "Chat"),
29
+ "ocr": ("mistralai_azure.ocr", "Ocr"),
30
+ }
25
31
 
26
32
  def __init__(
27
33
  self,
@@ -101,6 +107,9 @@ class MistralAzure(BaseSDK):
101
107
 
102
108
  hooks = SDKHooks()
103
109
 
110
+ # pylint: disable=protected-access
111
+ self.sdk_configuration.__dict__["_hooks"] = hooks
112
+
104
113
  current_server_url, *_ = self.sdk_configuration.get_server_details()
105
114
  server_url, self.sdk_configuration.client = hooks.sdk_init(
106
115
  current_server_url, client
@@ -108,9 +117,6 @@ class MistralAzure(BaseSDK):
108
117
  if current_server_url != server_url:
109
118
  self.sdk_configuration.server_url = server_url
110
119
 
111
- # pylint: disable=protected-access
112
- self.sdk_configuration.__dict__["_hooks"] = hooks
113
-
114
120
  weakref.finalize(
115
121
  self,
116
122
  close_clients,
@@ -121,10 +127,32 @@ class MistralAzure(BaseSDK):
121
127
  self.sdk_configuration.async_client_supplied,
122
128
  )
123
129
 
124
- self._init_sdks()
130
+ def __getattr__(self, name: str):
131
+ if name in self._sub_sdk_map:
132
+ module_path, class_name = self._sub_sdk_map[name]
133
+ try:
134
+ module = importlib.import_module(module_path)
135
+ klass = getattr(module, class_name)
136
+ instance = klass(self.sdk_configuration)
137
+ setattr(self, name, instance)
138
+ return instance
139
+ except ImportError as e:
140
+ raise AttributeError(
141
+ f"Failed to import module {module_path} for attribute {name}: {e}"
142
+ ) from e
143
+ except AttributeError as e:
144
+ raise AttributeError(
145
+ f"Failed to find class {class_name} in module {module_path} for attribute {name}: {e}"
146
+ ) from e
147
+
148
+ raise AttributeError(
149
+ f"'{type(self).__name__}' object has no attribute '{name}'"
150
+ )
125
151
 
126
- def _init_sdks(self):
127
- self.chat = Chat(self.sdk_configuration)
152
+ def __dir__(self):
153
+ default_attrs = list(super().__dir__())
154
+ lazy_attrs = list(self._sub_sdk_map.keys())
155
+ return sorted(list(set(default_attrs + lazy_attrs)))
128
156
 
129
157
  def __enter__(self):
130
158
  return self