mistralai 1.9.10__py3-none-any.whl → 1.10.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. mistralai/_hooks/registration.py +5 -0
  2. mistralai/_hooks/tracing.py +50 -0
  3. mistralai/_version.py +3 -3
  4. mistralai/accesses.py +51 -116
  5. mistralai/agents.py +58 -85
  6. mistralai/audio.py +8 -3
  7. mistralai/basesdk.py +15 -5
  8. mistralai/batch.py +6 -3
  9. mistralai/beta.py +10 -5
  10. mistralai/chat.py +70 -97
  11. mistralai/classifiers.py +57 -144
  12. mistralai/conversations.py +435 -412
  13. mistralai/documents.py +156 -359
  14. mistralai/embeddings.py +21 -42
  15. mistralai/extra/observability/__init__.py +15 -0
  16. mistralai/extra/observability/otel.py +393 -0
  17. mistralai/extra/run/tools.py +28 -16
  18. mistralai/files.py +53 -176
  19. mistralai/fim.py +46 -73
  20. mistralai/fine_tuning.py +6 -3
  21. mistralai/jobs.py +49 -158
  22. mistralai/libraries.py +71 -178
  23. mistralai/mistral_agents.py +298 -179
  24. mistralai/mistral_jobs.py +51 -138
  25. mistralai/models/__init__.py +94 -5
  26. mistralai/models/agent.py +15 -2
  27. mistralai/models/agentconversation.py +11 -3
  28. mistralai/models/agentcreationrequest.py +6 -2
  29. mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
  30. mistralai/models/agents_api_v1_agents_getop.py +40 -3
  31. mistralai/models/agents_api_v1_agents_listop.py +72 -2
  32. mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
  33. mistralai/models/agents_api_v1_conversations_listop.py +39 -2
  34. mistralai/models/agentscompletionrequest.py +21 -6
  35. mistralai/models/agentscompletionstreamrequest.py +21 -6
  36. mistralai/models/agentupdaterequest.py +18 -2
  37. mistralai/models/audiotranscriptionrequest.py +2 -0
  38. mistralai/models/batchjobin.py +10 -0
  39. mistralai/models/chatcompletionrequest.py +22 -5
  40. mistralai/models/chatcompletionstreamrequest.py +22 -5
  41. mistralai/models/conversationrequest.py +15 -4
  42. mistralai/models/conversationrestartrequest.py +50 -2
  43. mistralai/models/conversationrestartstreamrequest.py +50 -2
  44. mistralai/models/conversationstreamrequest.py +15 -4
  45. mistralai/models/documentout.py +26 -10
  46. mistralai/models/documentupdatein.py +24 -3
  47. mistralai/models/embeddingrequest.py +8 -8
  48. mistralai/models/files_api_routes_list_filesop.py +7 -0
  49. mistralai/models/fimcompletionrequest.py +8 -9
  50. mistralai/models/fimcompletionstreamrequest.py +8 -9
  51. mistralai/models/httpvalidationerror.py +11 -6
  52. mistralai/models/libraries_documents_list_v1op.py +15 -2
  53. mistralai/models/libraryout.py +10 -7
  54. mistralai/models/listfilesout.py +35 -4
  55. mistralai/models/mistralerror.py +26 -0
  56. mistralai/models/modelcapabilities.py +13 -4
  57. mistralai/models/modelconversation.py +8 -2
  58. mistralai/models/no_response_error.py +13 -0
  59. mistralai/models/ocrpageobject.py +26 -5
  60. mistralai/models/ocrrequest.py +17 -1
  61. mistralai/models/ocrtableobject.py +31 -0
  62. mistralai/models/prediction.py +4 -0
  63. mistralai/models/requestsource.py +7 -0
  64. mistralai/models/responseformat.py +4 -2
  65. mistralai/models/responseformats.py +0 -1
  66. mistralai/models/responsevalidationerror.py +25 -0
  67. mistralai/models/sdkerror.py +30 -14
  68. mistralai/models/sharingdelete.py +36 -5
  69. mistralai/models/sharingin.py +36 -5
  70. mistralai/models/sharingout.py +3 -3
  71. mistralai/models/toolexecutiondeltaevent.py +13 -4
  72. mistralai/models/toolexecutiondoneevent.py +13 -4
  73. mistralai/models/toolexecutionentry.py +9 -4
  74. mistralai/models/toolexecutionstartedevent.py +13 -4
  75. mistralai/models_.py +67 -212
  76. mistralai/ocr.py +33 -36
  77. mistralai/sdk.py +15 -2
  78. mistralai/transcriptions.py +21 -60
  79. mistralai/utils/__init__.py +18 -5
  80. mistralai/utils/eventstreaming.py +10 -0
  81. mistralai/utils/serializers.py +3 -2
  82. mistralai/utils/unmarshal_json_response.py +24 -0
  83. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/METADATA +89 -40
  84. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/RECORD +86 -75
  85. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info}/WHEEL +1 -1
  86. {mistralai-1.9.10.dist-info → mistralai-1.10.0.dist-info/licenses}/LICENSE +0 -0
@@ -13,33 +13,33 @@ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
13
13
  EmbeddingRequestInputsTypedDict = TypeAliasType(
14
14
  "EmbeddingRequestInputsTypedDict", Union[str, List[str]]
15
15
  )
16
- r"""Text to embed."""
16
+ r"""The text content to be embedded, can be a string or an array of strings for fast processing in bulk."""
17
17
 
18
18
 
19
19
  EmbeddingRequestInputs = TypeAliasType("EmbeddingRequestInputs", Union[str, List[str]])
20
- r"""Text to embed."""
20
+ r"""The text content to be embedded, can be a string or an array of strings for fast processing in bulk."""
21
21
 
22
22
 
23
23
  class EmbeddingRequestTypedDict(TypedDict):
24
24
  model: str
25
- r"""ID of the model to use."""
25
+ r"""The ID of the model to be used for embedding."""
26
26
  inputs: EmbeddingRequestInputsTypedDict
27
- r"""Text to embed."""
27
+ r"""The text content to be embedded, can be a string or an array of strings for fast processing in bulk."""
28
28
  output_dimension: NotRequired[Nullable[int]]
29
- r"""The dimension of the output embeddings."""
29
+ r"""The dimension of the output embeddings when feature available. If not provided, a default output dimension will be used."""
30
30
  output_dtype: NotRequired[EmbeddingDtype]
31
31
  encoding_format: NotRequired[EncodingFormat]
32
32
 
33
33
 
34
34
  class EmbeddingRequest(BaseModel):
35
35
  model: str
36
- r"""ID of the model to use."""
36
+ r"""The ID of the model to be used for embedding."""
37
37
 
38
38
  inputs: Annotated[EmbeddingRequestInputs, pydantic.Field(alias="input")]
39
- r"""Text to embed."""
39
+ r"""The text content to be embedded, can be a string or an array of strings for fast processing in bulk."""
40
40
 
41
41
  output_dimension: OptionalNullable[int] = UNSET
42
- r"""The dimension of the output embeddings."""
42
+ r"""The dimension of the output embeddings when feature available. If not provided, a default output dimension will be used."""
43
43
 
44
44
  output_dtype: Optional[EmbeddingDtype] = None
45
45
 
@@ -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
  ]
@@ -2,7 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .validationerror import ValidationError
5
- from mistralai import utils
5
+ import httpx
6
+ from mistralai.models import MistralError
6
7
  from mistralai.types import BaseModel
7
8
  from typing import List, Optional
8
9
 
@@ -11,11 +12,15 @@ class HTTPValidationErrorData(BaseModel):
11
12
  detail: Optional[List[ValidationError]] = None
12
13
 
13
14
 
14
- class HTTPValidationError(Exception):
15
+ class HTTPValidationError(MistralError):
15
16
  data: HTTPValidationErrorData
16
17
 
17
- def __init__(self, data: HTTPValidationErrorData):
18
+ def __init__(
19
+ self,
20
+ data: HTTPValidationErrorData,
21
+ raw_response: httpx.Response,
22
+ body: Optional[str] = None,
23
+ ):
24
+ message = body or raw_response.text
25
+ super().__init__(message, raw_response, body)
18
26
  self.data = data
19
-
20
- def __str__(self) -> str:
21
- return utils.marshal_json(self.data, HTTPValidationErrorData)
@@ -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
@@ -0,0 +1,26 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ import httpx
4
+ from typing import Optional
5
+
6
+
7
+ class MistralError(Exception):
8
+ """The base class for all HTTP error responses."""
9
+
10
+ message: str
11
+ status_code: int
12
+ body: str
13
+ headers: httpx.Headers
14
+ raw_response: httpx.Response
15
+
16
+ def __init__(
17
+ self, message: str, raw_response: httpx.Response, body: Optional[str] = None
18
+ ):
19
+ self.message = message
20
+ self.status_code = raw_response.status_code
21
+ self.body = body if body is not None else raw_response.text
22
+ self.headers = raw_response.headers
23
+ self.raw_response = raw_response
24
+
25
+ def __str__(self):
26
+ return self.message
@@ -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)
@@ -0,0 +1,13 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ class NoResponseError(Exception):
4
+ """Error raised when no HTTP response is received from the server."""
5
+
6
+ message: str
7
+
8
+ def __init__(self, message: str = "No response received"):
9
+ self.message = message
10
+ super().__init__(message)
11
+
12
+ def __str__(self):
13
+ return self.message
@@ -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"""