mistralai 1.9.11__py3-none-any.whl → 1.10.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.
Files changed (151) hide show
  1. mistralai/_hooks/registration.py +5 -0
  2. mistralai/_hooks/tracing.py +75 -0
  3. mistralai/_version.py +2 -2
  4. mistralai/accesses.py +8 -8
  5. mistralai/agents.py +29 -17
  6. mistralai/chat.py +41 -29
  7. mistralai/classifiers.py +13 -1
  8. mistralai/conversations.py +294 -62
  9. mistralai/documents.py +19 -3
  10. mistralai/embeddings.py +13 -7
  11. mistralai/extra/README.md +1 -1
  12. mistralai/extra/mcp/auth.py +10 -11
  13. mistralai/extra/mcp/base.py +17 -16
  14. mistralai/extra/mcp/sse.py +13 -15
  15. mistralai/extra/mcp/stdio.py +5 -6
  16. mistralai/extra/observability/__init__.py +15 -0
  17. mistralai/extra/observability/otel.py +372 -0
  18. mistralai/extra/run/context.py +33 -43
  19. mistralai/extra/run/result.py +29 -30
  20. mistralai/extra/run/tools.py +34 -23
  21. mistralai/extra/struct_chat.py +15 -8
  22. mistralai/extra/utils/response_format.py +5 -3
  23. mistralai/files.py +6 -0
  24. mistralai/fim.py +17 -5
  25. mistralai/mistral_agents.py +229 -1
  26. mistralai/mistral_jobs.py +39 -13
  27. mistralai/models/__init__.py +99 -3
  28. mistralai/models/agent.py +15 -2
  29. mistralai/models/agentconversation.py +11 -3
  30. mistralai/models/agentcreationrequest.py +6 -2
  31. mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
  32. mistralai/models/agents_api_v1_agents_getop.py +40 -3
  33. mistralai/models/agents_api_v1_agents_listop.py +72 -2
  34. mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
  35. mistralai/models/agents_api_v1_conversations_listop.py +39 -2
  36. mistralai/models/agentscompletionrequest.py +21 -6
  37. mistralai/models/agentscompletionstreamrequest.py +21 -6
  38. mistralai/models/agentupdaterequest.py +18 -2
  39. mistralai/models/audioencoding.py +13 -0
  40. mistralai/models/audioformat.py +19 -0
  41. mistralai/models/audiotranscriptionrequest.py +2 -0
  42. mistralai/models/batchjobin.py +26 -5
  43. mistralai/models/batchjobout.py +5 -0
  44. mistralai/models/batchrequest.py +48 -0
  45. mistralai/models/chatcompletionrequest.py +22 -5
  46. mistralai/models/chatcompletionstreamrequest.py +22 -5
  47. mistralai/models/classificationrequest.py +37 -3
  48. mistralai/models/conversationrequest.py +15 -4
  49. mistralai/models/conversationrestartrequest.py +50 -2
  50. mistralai/models/conversationrestartstreamrequest.py +50 -2
  51. mistralai/models/conversationstreamrequest.py +15 -4
  52. mistralai/models/documentout.py +26 -10
  53. mistralai/models/documentupdatein.py +24 -3
  54. mistralai/models/embeddingrequest.py +19 -11
  55. mistralai/models/files_api_routes_list_filesop.py +7 -0
  56. mistralai/models/fimcompletionrequest.py +8 -9
  57. mistralai/models/fimcompletionstreamrequest.py +8 -9
  58. mistralai/models/jobs_api_routes_batch_get_batch_jobop.py +40 -3
  59. mistralai/models/libraries_documents_list_v1op.py +15 -2
  60. mistralai/models/libraryout.py +10 -7
  61. mistralai/models/listfilesout.py +35 -4
  62. mistralai/models/modelcapabilities.py +13 -4
  63. mistralai/models/modelconversation.py +8 -2
  64. mistralai/models/ocrpageobject.py +26 -5
  65. mistralai/models/ocrrequest.py +17 -1
  66. mistralai/models/ocrtableobject.py +31 -0
  67. mistralai/models/prediction.py +4 -0
  68. mistralai/models/requestsource.py +7 -0
  69. mistralai/models/responseformat.py +4 -2
  70. mistralai/models/responseformats.py +0 -1
  71. mistralai/models/sharingdelete.py +36 -5
  72. mistralai/models/sharingin.py +36 -5
  73. mistralai/models/sharingout.py +3 -3
  74. mistralai/models/toolexecutiondeltaevent.py +13 -4
  75. mistralai/models/toolexecutiondoneevent.py +13 -4
  76. mistralai/models/toolexecutionentry.py +9 -4
  77. mistralai/models/toolexecutionstartedevent.py +13 -4
  78. mistralai/models/toolfilechunk.py +11 -4
  79. mistralai/models/toolreferencechunk.py +13 -4
  80. mistralai/models_.py +2 -14
  81. mistralai/ocr.py +18 -0
  82. mistralai/transcriptions.py +4 -4
  83. {mistralai-1.9.11.dist-info → mistralai-1.10.1.dist-info}/METADATA +162 -152
  84. {mistralai-1.9.11.dist-info → mistralai-1.10.1.dist-info}/RECORD +168 -144
  85. {mistralai-1.9.11.dist-info → mistralai-1.10.1.dist-info}/WHEEL +1 -1
  86. mistralai_azure/_version.py +3 -3
  87. mistralai_azure/basesdk.py +15 -5
  88. mistralai_azure/chat.py +59 -98
  89. mistralai_azure/models/__init__.py +50 -3
  90. mistralai_azure/models/chatcompletionrequest.py +16 -4
  91. mistralai_azure/models/chatcompletionstreamrequest.py +16 -4
  92. mistralai_azure/models/httpvalidationerror.py +11 -6
  93. mistralai_azure/models/mistralazureerror.py +26 -0
  94. mistralai_azure/models/no_response_error.py +13 -0
  95. mistralai_azure/models/prediction.py +4 -0
  96. mistralai_azure/models/responseformat.py +4 -2
  97. mistralai_azure/models/responseformats.py +0 -1
  98. mistralai_azure/models/responsevalidationerror.py +25 -0
  99. mistralai_azure/models/sdkerror.py +30 -14
  100. mistralai_azure/models/systemmessage.py +7 -3
  101. mistralai_azure/models/systemmessagecontentchunks.py +21 -0
  102. mistralai_azure/models/thinkchunk.py +35 -0
  103. mistralai_azure/ocr.py +15 -36
  104. mistralai_azure/utils/__init__.py +18 -5
  105. mistralai_azure/utils/eventstreaming.py +10 -0
  106. mistralai_azure/utils/serializers.py +3 -2
  107. mistralai_azure/utils/unmarshal_json_response.py +24 -0
  108. mistralai_gcp/_hooks/types.py +7 -0
  109. mistralai_gcp/_version.py +4 -4
  110. mistralai_gcp/basesdk.py +27 -25
  111. mistralai_gcp/chat.py +75 -98
  112. mistralai_gcp/fim.py +39 -74
  113. mistralai_gcp/httpclient.py +6 -16
  114. mistralai_gcp/models/__init__.py +321 -116
  115. mistralai_gcp/models/assistantmessage.py +1 -1
  116. mistralai_gcp/models/chatcompletionrequest.py +36 -7
  117. mistralai_gcp/models/chatcompletionresponse.py +6 -6
  118. mistralai_gcp/models/chatcompletionstreamrequest.py +36 -7
  119. mistralai_gcp/models/completionresponsestreamchoice.py +1 -1
  120. mistralai_gcp/models/deltamessage.py +1 -1
  121. mistralai_gcp/models/fimcompletionrequest.py +3 -9
  122. mistralai_gcp/models/fimcompletionresponse.py +6 -6
  123. mistralai_gcp/models/fimcompletionstreamrequest.py +3 -9
  124. mistralai_gcp/models/httpvalidationerror.py +11 -6
  125. mistralai_gcp/models/imageurl.py +1 -1
  126. mistralai_gcp/models/jsonschema.py +1 -1
  127. mistralai_gcp/models/mistralgcperror.py +26 -0
  128. mistralai_gcp/models/mistralpromptmode.py +8 -0
  129. mistralai_gcp/models/no_response_error.py +13 -0
  130. mistralai_gcp/models/prediction.py +4 -0
  131. mistralai_gcp/models/responseformat.py +5 -3
  132. mistralai_gcp/models/responseformats.py +0 -1
  133. mistralai_gcp/models/responsevalidationerror.py +25 -0
  134. mistralai_gcp/models/sdkerror.py +30 -14
  135. mistralai_gcp/models/systemmessage.py +7 -3
  136. mistralai_gcp/models/systemmessagecontentchunks.py +21 -0
  137. mistralai_gcp/models/thinkchunk.py +35 -0
  138. mistralai_gcp/models/toolmessage.py +1 -1
  139. mistralai_gcp/models/usageinfo.py +71 -8
  140. mistralai_gcp/models/usermessage.py +1 -1
  141. mistralai_gcp/sdk.py +12 -10
  142. mistralai_gcp/sdkconfiguration.py +0 -7
  143. mistralai_gcp/types/basemodel.py +3 -3
  144. mistralai_gcp/utils/__init__.py +143 -45
  145. mistralai_gcp/utils/datetimes.py +23 -0
  146. mistralai_gcp/utils/enums.py +67 -27
  147. mistralai_gcp/utils/eventstreaming.py +10 -0
  148. mistralai_gcp/utils/forms.py +49 -28
  149. mistralai_gcp/utils/serializers.py +33 -3
  150. mistralai_gcp/utils/unmarshal_json_response.py +24 -0
  151. {mistralai-1.9.11.dist-info → mistralai-1.10.1.dist-info}/licenses/LICENSE +0 -0
@@ -15,6 +15,7 @@ from typing_extensions import Annotated, NotRequired, TypedDict
15
15
  class FilesAPIRoutesListFilesRequestTypedDict(TypedDict):
16
16
  page: NotRequired[int]
17
17
  page_size: NotRequired[int]
18
+ include_total: NotRequired[bool]
18
19
  sample_type: NotRequired[Nullable[List[SampleType]]]
19
20
  source: NotRequired[Nullable[List[Source]]]
20
21
  search: NotRequired[Nullable[str]]
@@ -32,6 +33,11 @@ class FilesAPIRoutesListFilesRequest(BaseModel):
32
33
  FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
33
34
  ] = 100
34
35
 
36
+ include_total: Annotated[
37
+ Optional[bool],
38
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
39
+ ] = True
40
+
35
41
  sample_type: Annotated[
36
42
  OptionalNullable[
37
43
  List[Annotated[SampleType, PlainValidator(validate_open_enum(False))]]
@@ -63,6 +69,7 @@ class FilesAPIRoutesListFilesRequest(BaseModel):
63
69
  optional_fields = [
64
70
  "page",
65
71
  "page_size",
72
+ "include_total",
66
73
  "sample_type",
67
74
  "source",
68
75
  "search",
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
5
  from pydantic import model_serializer
6
- from typing import List, Optional, Union
6
+ from typing import Any, Dict, List, Optional, Union
7
7
  from typing_extensions import NotRequired, TypeAliasType, TypedDict
8
8
 
9
9
 
@@ -21,10 +21,7 @@ r"""Stop generation if this token is detected. Or if one of these tokens is dete
21
21
 
22
22
  class FIMCompletionRequestTypedDict(TypedDict):
23
23
  model: str
24
- r"""ID of the model to use. Only compatible for now with:
25
- - `codestral-2405`
26
- - `codestral-latest`
27
- """
24
+ r"""ID of the model with FIM to use."""
28
25
  prompt: str
29
26
  r"""The text/code to complete."""
30
27
  temperature: NotRequired[Nullable[float]]
@@ -39,6 +36,7 @@ class FIMCompletionRequestTypedDict(TypedDict):
39
36
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
40
37
  random_seed: NotRequired[Nullable[int]]
41
38
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
39
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
42
40
  suffix: NotRequired[Nullable[str]]
43
41
  r"""Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`."""
44
42
  min_tokens: NotRequired[Nullable[int]]
@@ -47,10 +45,7 @@ class FIMCompletionRequestTypedDict(TypedDict):
47
45
 
48
46
  class FIMCompletionRequest(BaseModel):
49
47
  model: str
50
- r"""ID of the model to use. Only compatible for now with:
51
- - `codestral-2405`
52
- - `codestral-latest`
53
- """
48
+ r"""ID of the model with FIM to use."""
54
49
 
55
50
  prompt: str
56
51
  r"""The text/code to complete."""
@@ -73,6 +68,8 @@ class FIMCompletionRequest(BaseModel):
73
68
  random_seed: OptionalNullable[int] = UNSET
74
69
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
75
70
 
71
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
72
+
76
73
  suffix: OptionalNullable[str] = UNSET
77
74
  r"""Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`."""
78
75
 
@@ -88,6 +85,7 @@ class FIMCompletionRequest(BaseModel):
88
85
  "stream",
89
86
  "stop",
90
87
  "random_seed",
88
+ "metadata",
91
89
  "suffix",
92
90
  "min_tokens",
93
91
  ]
@@ -95,6 +93,7 @@ class FIMCompletionRequest(BaseModel):
95
93
  "temperature",
96
94
  "max_tokens",
97
95
  "random_seed",
96
+ "metadata",
98
97
  "suffix",
99
98
  "min_tokens",
100
99
  ]
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
5
  from pydantic import model_serializer
6
- from typing import List, Optional, Union
6
+ from typing import Any, Dict, List, Optional, Union
7
7
  from typing_extensions import NotRequired, TypeAliasType, TypedDict
8
8
 
9
9
 
@@ -21,10 +21,7 @@ r"""Stop generation if this token is detected. Or if one of these tokens is dete
21
21
 
22
22
  class FIMCompletionStreamRequestTypedDict(TypedDict):
23
23
  model: str
24
- r"""ID of the model to use. Only compatible for now with:
25
- - `codestral-2405`
26
- - `codestral-latest`
27
- """
24
+ r"""ID of the model with FIM to use."""
28
25
  prompt: str
29
26
  r"""The text/code to complete."""
30
27
  temperature: NotRequired[Nullable[float]]
@@ -38,6 +35,7 @@ class FIMCompletionStreamRequestTypedDict(TypedDict):
38
35
  r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
39
36
  random_seed: NotRequired[Nullable[int]]
40
37
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
38
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
41
39
  suffix: NotRequired[Nullable[str]]
42
40
  r"""Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`."""
43
41
  min_tokens: NotRequired[Nullable[int]]
@@ -46,10 +44,7 @@ class FIMCompletionStreamRequestTypedDict(TypedDict):
46
44
 
47
45
  class FIMCompletionStreamRequest(BaseModel):
48
46
  model: str
49
- r"""ID of the model to use. Only compatible for now with:
50
- - `codestral-2405`
51
- - `codestral-latest`
52
- """
47
+ r"""ID of the model with FIM to use."""
53
48
 
54
49
  prompt: str
55
50
  r"""The text/code to complete."""
@@ -71,6 +66,8 @@ class FIMCompletionStreamRequest(BaseModel):
71
66
  random_seed: OptionalNullable[int] = UNSET
72
67
  r"""The seed to use for random sampling. If set, different calls will generate deterministic results."""
73
68
 
69
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
70
+
74
71
  suffix: OptionalNullable[str] = UNSET
75
72
  r"""Optional text/code that adds more context for the model. When given a `prompt` and a `suffix` the model will fill what is between them. When `suffix` is not provided, the model will simply execute completion starting with `prompt`."""
76
73
 
@@ -86,6 +83,7 @@ class FIMCompletionStreamRequest(BaseModel):
86
83
  "stream",
87
84
  "stop",
88
85
  "random_seed",
86
+ "metadata",
89
87
  "suffix",
90
88
  "min_tokens",
91
89
  ]
@@ -93,6 +91,7 @@ class FIMCompletionStreamRequest(BaseModel):
93
91
  "temperature",
94
92
  "max_tokens",
95
93
  "random_seed",
94
+ "metadata",
96
95
  "suffix",
97
96
  "min_tokens",
98
97
  ]
@@ -1,16 +1,53 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from mistralai.types import BaseModel
5
- from mistralai.utils import FieldMetadata, PathParamMetadata
6
- from typing_extensions import Annotated, TypedDict
4
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
+ from mistralai.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
6
+ from pydantic import model_serializer
7
+ from typing_extensions import Annotated, NotRequired, TypedDict
7
8
 
8
9
 
9
10
  class JobsAPIRoutesBatchGetBatchJobRequestTypedDict(TypedDict):
10
11
  job_id: str
12
+ inline: NotRequired[Nullable[bool]]
11
13
 
12
14
 
13
15
  class JobsAPIRoutesBatchGetBatchJobRequest(BaseModel):
14
16
  job_id: Annotated[
15
17
  str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
16
18
  ]
19
+
20
+ inline: Annotated[
21
+ OptionalNullable[bool],
22
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
23
+ ] = UNSET
24
+
25
+ @model_serializer(mode="wrap")
26
+ def serialize_model(self, handler):
27
+ optional_fields = ["inline"]
28
+ nullable_fields = ["inline"]
29
+ null_default_fields = []
30
+
31
+ serialized = handler(self)
32
+
33
+ m = {}
34
+
35
+ for n, f in type(self).model_fields.items():
36
+ k = f.alias or n
37
+ val = serialized.get(k)
38
+ serialized.pop(k, None)
39
+
40
+ optional_nullable = k in optional_fields and k in nullable_fields
41
+ is_set = (
42
+ self.__pydantic_fields_set__.intersection({n})
43
+ or k in null_default_fields
44
+ ) # pylint: disable=no-member
45
+
46
+ if val is not None and val != UNSET_SENTINEL:
47
+ m[k] = val
48
+ elif val != UNSET_SENTINEL and (
49
+ not k in optional_fields or (optional_nullable and is_set)
50
+ ):
51
+ m[k] = val
52
+
53
+ return m
@@ -13,6 +13,7 @@ class LibrariesDocumentsListV1RequestTypedDict(TypedDict):
13
13
  search: NotRequired[Nullable[str]]
14
14
  page_size: NotRequired[int]
15
15
  page: NotRequired[int]
16
+ filters_attributes: NotRequired[Nullable[str]]
16
17
  sort_by: NotRequired[str]
17
18
  sort_order: NotRequired[str]
18
19
 
@@ -37,6 +38,11 @@ class LibrariesDocumentsListV1Request(BaseModel):
37
38
  FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
38
39
  ] = 0
39
40
 
41
+ filters_attributes: Annotated[
42
+ OptionalNullable[str],
43
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
44
+ ] = UNSET
45
+
40
46
  sort_by: Annotated[
41
47
  Optional[str],
42
48
  FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
@@ -49,8 +55,15 @@ class LibrariesDocumentsListV1Request(BaseModel):
49
55
 
50
56
  @model_serializer(mode="wrap")
51
57
  def serialize_model(self, handler):
52
- optional_fields = ["search", "page_size", "page", "sort_by", "sort_order"]
53
- nullable_fields = ["search"]
58
+ optional_fields = [
59
+ "search",
60
+ "page_size",
61
+ "page",
62
+ "filters_attributes",
63
+ "sort_by",
64
+ "sort_order",
65
+ ]
66
+ nullable_fields = ["search", "filters_attributes"]
54
67
  null_default_fields = []
55
68
 
56
69
  serialized = handler(self)
@@ -12,18 +12,19 @@ class LibraryOutTypedDict(TypedDict):
12
12
  name: str
13
13
  created_at: datetime
14
14
  updated_at: datetime
15
- owner_id: str
15
+ owner_id: Nullable[str]
16
16
  owner_type: str
17
17
  total_size: int
18
18
  nb_documents: int
19
19
  chunk_size: Nullable[int]
20
20
  emoji: NotRequired[Nullable[str]]
21
21
  description: NotRequired[Nullable[str]]
22
- generated_name: NotRequired[Nullable[str]]
23
22
  generated_description: NotRequired[Nullable[str]]
24
23
  explicit_user_members_count: NotRequired[Nullable[int]]
25
24
  explicit_workspace_members_count: NotRequired[Nullable[int]]
26
25
  org_sharing_role: NotRequired[Nullable[str]]
26
+ generated_name: NotRequired[Nullable[str]]
27
+ r"""Generated Name"""
27
28
 
28
29
 
29
30
  class LibraryOut(BaseModel):
@@ -35,7 +36,7 @@ class LibraryOut(BaseModel):
35
36
 
36
37
  updated_at: datetime
37
38
 
38
- owner_id: str
39
+ owner_id: Nullable[str]
39
40
 
40
41
  owner_type: str
41
42
 
@@ -49,8 +50,6 @@ class LibraryOut(BaseModel):
49
50
 
50
51
  description: OptionalNullable[str] = UNSET
51
52
 
52
- generated_name: OptionalNullable[str] = UNSET
53
-
54
53
  generated_description: OptionalNullable[str] = UNSET
55
54
 
56
55
  explicit_user_members_count: OptionalNullable[int] = UNSET
@@ -59,26 +58,30 @@ class LibraryOut(BaseModel):
59
58
 
60
59
  org_sharing_role: OptionalNullable[str] = UNSET
61
60
 
61
+ generated_name: OptionalNullable[str] = UNSET
62
+ r"""Generated Name"""
63
+
62
64
  @model_serializer(mode="wrap")
63
65
  def serialize_model(self, handler):
64
66
  optional_fields = [
65
67
  "emoji",
66
68
  "description",
67
- "generated_name",
68
69
  "generated_description",
69
70
  "explicit_user_members_count",
70
71
  "explicit_workspace_members_count",
71
72
  "org_sharing_role",
73
+ "generated_name",
72
74
  ]
73
75
  nullable_fields = [
76
+ "owner_id",
74
77
  "chunk_size",
75
78
  "emoji",
76
79
  "description",
77
- "generated_name",
78
80
  "generated_description",
79
81
  "explicit_user_members_count",
80
82
  "explicit_workspace_members_count",
81
83
  "org_sharing_role",
84
+ "generated_name",
82
85
  ]
83
86
  null_default_fields = []
84
87
 
@@ -2,15 +2,16 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .fileschema import FileSchema, FileSchemaTypedDict
5
- from mistralai.types import BaseModel
5
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
+ from pydantic import model_serializer
6
7
  from typing import List
7
- from typing_extensions import TypedDict
8
+ from typing_extensions import NotRequired, TypedDict
8
9
 
9
10
 
10
11
  class ListFilesOutTypedDict(TypedDict):
11
12
  data: List[FileSchemaTypedDict]
12
13
  object: str
13
- total: int
14
+ total: NotRequired[Nullable[int]]
14
15
 
15
16
 
16
17
  class ListFilesOut(BaseModel):
@@ -18,4 +19,34 @@ class ListFilesOut(BaseModel):
18
19
 
19
20
  object: str
20
21
 
21
- total: int
22
+ total: OptionalNullable[int] = UNSET
23
+
24
+ @model_serializer(mode="wrap")
25
+ def serialize_model(self, handler):
26
+ optional_fields = ["total"]
27
+ nullable_fields = ["total"]
28
+ null_default_fields = []
29
+
30
+ serialized = handler(self)
31
+
32
+ m = {}
33
+
34
+ for n, f in type(self).model_fields.items():
35
+ k = f.alias or n
36
+ val = serialized.get(k)
37
+ serialized.pop(k, None)
38
+
39
+ optional_nullable = k in optional_fields and k in nullable_fields
40
+ is_set = (
41
+ self.__pydantic_fields_set__.intersection({n})
42
+ or k in null_default_fields
43
+ ) # pylint: disable=no-member
44
+
45
+ if val is not None and val != UNSET_SENTINEL:
46
+ m[k] = val
47
+ elif val != UNSET_SENTINEL and (
48
+ not k in optional_fields or (optional_nullable and is_set)
49
+ ):
50
+ m[k] = val
51
+
52
+ return m
@@ -8,22 +8,31 @@ from typing_extensions import NotRequired, TypedDict
8
8
 
9
9
  class ModelCapabilitiesTypedDict(TypedDict):
10
10
  completion_chat: NotRequired[bool]
11
- completion_fim: NotRequired[bool]
12
11
  function_calling: NotRequired[bool]
12
+ completion_fim: NotRequired[bool]
13
13
  fine_tuning: NotRequired[bool]
14
14
  vision: NotRequired[bool]
15
+ ocr: NotRequired[bool]
15
16
  classification: NotRequired[bool]
17
+ moderation: NotRequired[bool]
18
+ audio: NotRequired[bool]
16
19
 
17
20
 
18
21
  class ModelCapabilities(BaseModel):
19
- completion_chat: Optional[bool] = True
22
+ completion_chat: Optional[bool] = False
20
23
 
21
- completion_fim: Optional[bool] = False
24
+ function_calling: Optional[bool] = False
22
25
 
23
- function_calling: Optional[bool] = True
26
+ completion_fim: Optional[bool] = False
24
27
 
25
28
  fine_tuning: Optional[bool] = False
26
29
 
27
30
  vision: Optional[bool] = False
28
31
 
32
+ ocr: Optional[bool] = False
33
+
29
34
  classification: Optional[bool] = False
35
+
36
+ moderation: Optional[bool] = False
37
+
38
+ audio: Optional[bool] = False
@@ -12,7 +12,7 @@ from datetime import datetime
12
12
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
13
13
  from mistralai.utils import get_discriminator
14
14
  from pydantic import Discriminator, Tag, model_serializer
15
- from typing import List, Literal, Optional, Union
15
+ from typing import Any, Dict, List, Literal, Optional, Union
16
16
  from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
17
17
 
18
18
 
@@ -60,6 +60,8 @@ class ModelConversationTypedDict(TypedDict):
60
60
  r"""Name given to the conversation."""
61
61
  description: NotRequired[Nullable[str]]
62
62
  r"""Description of the what the conversation is about."""
63
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
64
+ r"""Custom metadata for the conversation."""
63
65
  object: NotRequired[ModelConversationObject]
64
66
 
65
67
 
@@ -87,6 +89,9 @@ class ModelConversation(BaseModel):
87
89
  description: OptionalNullable[str] = UNSET
88
90
  r"""Description of the what the conversation is about."""
89
91
 
92
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
93
+ r"""Custom metadata for the conversation."""
94
+
90
95
  object: Optional[ModelConversationObject] = "conversation"
91
96
 
92
97
  @model_serializer(mode="wrap")
@@ -97,9 +102,10 @@ class ModelConversation(BaseModel):
97
102
  "completion_args",
98
103
  "name",
99
104
  "description",
105
+ "metadata",
100
106
  "object",
101
107
  ]
102
- nullable_fields = ["instructions", "name", "description"]
108
+ nullable_fields = ["instructions", "name", "description", "metadata"]
103
109
  null_default_fields = []
104
110
 
105
111
  serialized = handler(self)
@@ -3,10 +3,11 @@
3
3
  from __future__ import annotations
4
4
  from .ocrimageobject import OCRImageObject, OCRImageObjectTypedDict
5
5
  from .ocrpagedimensions import OCRPageDimensions, OCRPageDimensionsTypedDict
6
- from mistralai.types import BaseModel, Nullable, UNSET_SENTINEL
6
+ from .ocrtableobject import OCRTableObject, OCRTableObjectTypedDict
7
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
8
  from pydantic import model_serializer
8
- from typing import List
9
- from typing_extensions import TypedDict
9
+ from typing import List, Optional
10
+ from typing_extensions import NotRequired, TypedDict
10
11
 
11
12
 
12
13
  class OCRPageObjectTypedDict(TypedDict):
@@ -18,6 +19,14 @@ class OCRPageObjectTypedDict(TypedDict):
18
19
  r"""List of all extracted images in the page"""
19
20
  dimensions: Nullable[OCRPageDimensionsTypedDict]
20
21
  r"""The dimensions of the PDF Page's screenshot image"""
22
+ tables: NotRequired[List[OCRTableObjectTypedDict]]
23
+ r"""List of all extracted tables in the page"""
24
+ hyperlinks: NotRequired[List[str]]
25
+ r"""List of all hyperlinks in the page"""
26
+ header: NotRequired[Nullable[str]]
27
+ r"""Header of the page"""
28
+ footer: NotRequired[Nullable[str]]
29
+ r"""Footer of the page"""
21
30
 
22
31
 
23
32
  class OCRPageObject(BaseModel):
@@ -33,10 +42,22 @@ class OCRPageObject(BaseModel):
33
42
  dimensions: Nullable[OCRPageDimensions]
34
43
  r"""The dimensions of the PDF Page's screenshot image"""
35
44
 
45
+ tables: Optional[List[OCRTableObject]] = None
46
+ r"""List of all extracted tables in the page"""
47
+
48
+ hyperlinks: Optional[List[str]] = None
49
+ r"""List of all hyperlinks in the page"""
50
+
51
+ header: OptionalNullable[str] = UNSET
52
+ r"""Header of the page"""
53
+
54
+ footer: OptionalNullable[str] = UNSET
55
+ r"""Footer of the page"""
56
+
36
57
  @model_serializer(mode="wrap")
37
58
  def serialize_model(self, handler):
38
- optional_fields = []
39
- nullable_fields = ["dimensions"]
59
+ optional_fields = ["tables", "hyperlinks", "header", "footer"]
60
+ nullable_fields = ["header", "footer", "dimensions"]
40
61
  null_default_fields = []
41
62
 
42
63
  serialized = handler(self)
@@ -7,7 +7,7 @@ from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
7
7
  from .responseformat import ResponseFormat, ResponseFormatTypedDict
8
8
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
9
9
  from pydantic import model_serializer
10
- from typing import List, Optional, Union
10
+ from typing import List, Literal, Optional, Union
11
11
  from typing_extensions import NotRequired, TypeAliasType, TypedDict
12
12
 
13
13
 
@@ -22,6 +22,9 @@ Document = TypeAliasType("Document", Union[FileChunk, ImageURLChunk, DocumentURL
22
22
  r"""Document to run OCR on"""
23
23
 
24
24
 
25
+ TableFormat = Literal["markdown", "html"]
26
+
27
+
25
28
  class OCRRequestTypedDict(TypedDict):
26
29
  model: Nullable[str]
27
30
  document: DocumentTypedDict
@@ -39,6 +42,9 @@ class OCRRequestTypedDict(TypedDict):
39
42
  r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
40
43
  document_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
41
44
  r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
45
+ table_format: NotRequired[Nullable[TableFormat]]
46
+ extract_header: NotRequired[bool]
47
+ extract_footer: NotRequired[bool]
42
48
 
43
49
 
44
50
  class OCRRequest(BaseModel):
@@ -67,6 +73,12 @@ class OCRRequest(BaseModel):
67
73
  document_annotation_format: OptionalNullable[ResponseFormat] = UNSET
68
74
  r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
69
75
 
76
+ table_format: OptionalNullable[TableFormat] = UNSET
77
+
78
+ extract_header: Optional[bool] = None
79
+
80
+ extract_footer: Optional[bool] = None
81
+
70
82
  @model_serializer(mode="wrap")
71
83
  def serialize_model(self, handler):
72
84
  optional_fields = [
@@ -77,6 +89,9 @@ class OCRRequest(BaseModel):
77
89
  "image_min_size",
78
90
  "bbox_annotation_format",
79
91
  "document_annotation_format",
92
+ "table_format",
93
+ "extract_header",
94
+ "extract_footer",
80
95
  ]
81
96
  nullable_fields = [
82
97
  "model",
@@ -86,6 +101,7 @@ class OCRRequest(BaseModel):
86
101
  "image_min_size",
87
102
  "bbox_annotation_format",
88
103
  "document_annotation_format",
104
+ "table_format",
89
105
  ]
90
106
  null_default_fields = []
91
107
 
@@ -0,0 +1,31 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai.types import BaseModel
5
+ import pydantic
6
+ from typing import Literal
7
+ from typing_extensions import Annotated, TypedDict
8
+
9
+
10
+ Format = Literal["markdown", "html"]
11
+ r"""Format of the table"""
12
+
13
+
14
+ class OCRTableObjectTypedDict(TypedDict):
15
+ id: str
16
+ r"""Table ID for extracted table in a page"""
17
+ content: str
18
+ r"""Content of the table in the given format"""
19
+ format_: Format
20
+ r"""Format of the table"""
21
+
22
+
23
+ class OCRTableObject(BaseModel):
24
+ id: str
25
+ r"""Table ID for extracted table in a page"""
26
+
27
+ content: str
28
+ r"""Content of the table in the given format"""
29
+
30
+ format_: Annotated[Format, pydantic.Field(alias="format")]
31
+ r"""Format of the table"""
@@ -10,11 +10,15 @@ from typing_extensions import Annotated, NotRequired, TypedDict
10
10
 
11
11
 
12
12
  class PredictionTypedDict(TypedDict):
13
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
14
+
13
15
  type: Literal["content"]
14
16
  content: NotRequired[str]
15
17
 
16
18
 
17
19
  class Prediction(BaseModel):
20
+ r"""Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content."""
21
+
18
22
  TYPE: Annotated[
19
23
  Annotated[
20
24
  Optional[Literal["content"]], AfterValidator(validate_const("content"))
@@ -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
+ RequestSource = Literal["api", "playground", "agent_builder_v1"]
@@ -10,14 +10,16 @@ from typing_extensions import NotRequired, TypedDict
10
10
 
11
11
 
12
12
  class ResponseFormatTypedDict(TypedDict):
13
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
14
+
13
15
  type: NotRequired[ResponseFormats]
14
- r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
15
16
  json_schema: NotRequired[Nullable[JSONSchemaTypedDict]]
16
17
 
17
18
 
18
19
  class ResponseFormat(BaseModel):
20
+ r"""Specify the format that the model must output. By default it will use `{ \"type\": \"text\" }`. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ \"type\": \"json_schema\" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide."""
21
+
19
22
  type: Optional[ResponseFormats] = None
20
- r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""
21
23
 
22
24
  json_schema: OptionalNullable[JSONSchema] = UNSET
23
25
 
@@ -5,4 +5,3 @@ from typing import Literal
5
5
 
6
6
 
7
7
  ResponseFormats = Literal["text", "json_object", "json_schema"]
8
- r"""An object specifying the format that the model must output. Setting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message."""