mistralai 1.9.11__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 (68) hide show
  1. mistralai/_hooks/registration.py +5 -0
  2. mistralai/_hooks/tracing.py +50 -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/conversations.py +294 -62
  8. mistralai/documents.py +19 -3
  9. mistralai/embeddings.py +6 -6
  10. mistralai/extra/observability/__init__.py +15 -0
  11. mistralai/extra/observability/otel.py +393 -0
  12. mistralai/extra/run/tools.py +28 -16
  13. mistralai/files.py +6 -0
  14. mistralai/fim.py +17 -5
  15. mistralai/mistral_agents.py +229 -1
  16. mistralai/mistral_jobs.py +10 -10
  17. mistralai/models/__init__.py +69 -2
  18. mistralai/models/agent.py +15 -2
  19. mistralai/models/agentconversation.py +11 -3
  20. mistralai/models/agentcreationrequest.py +6 -2
  21. mistralai/models/agents_api_v1_agents_deleteop.py +16 -0
  22. mistralai/models/agents_api_v1_agents_getop.py +40 -3
  23. mistralai/models/agents_api_v1_agents_listop.py +72 -2
  24. mistralai/models/agents_api_v1_conversations_deleteop.py +18 -0
  25. mistralai/models/agents_api_v1_conversations_listop.py +39 -2
  26. mistralai/models/agentscompletionrequest.py +21 -6
  27. mistralai/models/agentscompletionstreamrequest.py +21 -6
  28. mistralai/models/agentupdaterequest.py +18 -2
  29. mistralai/models/audiotranscriptionrequest.py +2 -0
  30. mistralai/models/batchjobin.py +10 -0
  31. mistralai/models/chatcompletionrequest.py +22 -5
  32. mistralai/models/chatcompletionstreamrequest.py +22 -5
  33. mistralai/models/conversationrequest.py +15 -4
  34. mistralai/models/conversationrestartrequest.py +50 -2
  35. mistralai/models/conversationrestartstreamrequest.py +50 -2
  36. mistralai/models/conversationstreamrequest.py +15 -4
  37. mistralai/models/documentout.py +26 -10
  38. mistralai/models/documentupdatein.py +24 -3
  39. mistralai/models/embeddingrequest.py +8 -8
  40. mistralai/models/files_api_routes_list_filesop.py +7 -0
  41. mistralai/models/fimcompletionrequest.py +8 -9
  42. mistralai/models/fimcompletionstreamrequest.py +8 -9
  43. mistralai/models/libraries_documents_list_v1op.py +15 -2
  44. mistralai/models/libraryout.py +10 -7
  45. mistralai/models/listfilesout.py +35 -4
  46. mistralai/models/modelcapabilities.py +13 -4
  47. mistralai/models/modelconversation.py +8 -2
  48. mistralai/models/ocrpageobject.py +26 -5
  49. mistralai/models/ocrrequest.py +17 -1
  50. mistralai/models/ocrtableobject.py +31 -0
  51. mistralai/models/prediction.py +4 -0
  52. mistralai/models/requestsource.py +7 -0
  53. mistralai/models/responseformat.py +4 -2
  54. mistralai/models/responseformats.py +0 -1
  55. mistralai/models/sharingdelete.py +36 -5
  56. mistralai/models/sharingin.py +36 -5
  57. mistralai/models/sharingout.py +3 -3
  58. mistralai/models/toolexecutiondeltaevent.py +13 -4
  59. mistralai/models/toolexecutiondoneevent.py +13 -4
  60. mistralai/models/toolexecutionentry.py +9 -4
  61. mistralai/models/toolexecutionstartedevent.py +13 -4
  62. mistralai/models_.py +2 -14
  63. mistralai/ocr.py +18 -0
  64. mistralai/transcriptions.py +4 -4
  65. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/METADATA +30 -12
  66. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/RECORD +68 -61
  67. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/WHEEL +0 -0
  68. {mistralai-1.9.11.dist-info → mistralai-1.10.0.dist-info}/licenses/LICENSE +0 -0
@@ -3,8 +3,9 @@
3
3
  from __future__ import annotations
4
4
  from .completionargs import CompletionArgs, CompletionArgsTypedDict
5
5
  from .conversationinputs import ConversationInputs, ConversationInputsTypedDict
6
- from mistralai.types import BaseModel
7
- from typing import Literal, Optional
6
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
+ from pydantic import model_serializer
8
+ from typing import Any, Dict, Literal, Optional
8
9
  from typing_extensions import NotRequired, TypedDict
9
10
 
10
11
 
@@ -22,6 +23,10 @@ class ConversationRestartStreamRequestTypedDict(TypedDict):
22
23
  handoff_execution: NotRequired[ConversationRestartStreamRequestHandoffExecution]
23
24
  completion_args: NotRequired[CompletionArgsTypedDict]
24
25
  r"""White-listed arguments from the completion API"""
26
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
27
+ r"""Custom metadata for the conversation."""
28
+ agent_version: NotRequired[Nullable[int]]
29
+ r"""Specific version of the agent to use when restarting. If not provided, uses the current version."""
25
30
 
26
31
 
27
32
  class ConversationRestartStreamRequest(BaseModel):
@@ -42,3 +47,46 @@ class ConversationRestartStreamRequest(BaseModel):
42
47
 
43
48
  completion_args: Optional[CompletionArgs] = None
44
49
  r"""White-listed arguments from the completion API"""
50
+
51
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
52
+ r"""Custom metadata for the conversation."""
53
+
54
+ agent_version: OptionalNullable[int] = UNSET
55
+ r"""Specific version of the agent to use when restarting. If not provided, uses the current version."""
56
+
57
+ @model_serializer(mode="wrap")
58
+ def serialize_model(self, handler):
59
+ optional_fields = [
60
+ "stream",
61
+ "store",
62
+ "handoff_execution",
63
+ "completion_args",
64
+ "metadata",
65
+ "agent_version",
66
+ ]
67
+ nullable_fields = ["metadata", "agent_version"]
68
+ null_default_fields = []
69
+
70
+ serialized = handler(self)
71
+
72
+ m = {}
73
+
74
+ for n, f in type(self).model_fields.items():
75
+ k = f.alias or n
76
+ val = serialized.get(k)
77
+ serialized.pop(k, None)
78
+
79
+ optional_nullable = k in optional_fields and k in nullable_fields
80
+ is_set = (
81
+ self.__pydantic_fields_set__.intersection({n})
82
+ or k in null_default_fields
83
+ ) # pylint: disable=no-member
84
+
85
+ if val is not None and val != UNSET_SENTINEL:
86
+ m[k] = val
87
+ elif val != UNSET_SENTINEL and (
88
+ not k in optional_fields or (optional_nullable and is_set)
89
+ ):
90
+ m[k] = val
91
+
92
+ return m
@@ -12,7 +12,7 @@ from .websearchtool import WebSearchTool, WebSearchToolTypedDict
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
 
@@ -50,11 +50,14 @@ class ConversationStreamRequestTypedDict(TypedDict):
50
50
  store: NotRequired[Nullable[bool]]
51
51
  handoff_execution: NotRequired[Nullable[ConversationStreamRequestHandoffExecution]]
52
52
  instructions: NotRequired[Nullable[str]]
53
- tools: NotRequired[Nullable[List[ConversationStreamRequestToolsTypedDict]]]
53
+ tools: NotRequired[List[ConversationStreamRequestToolsTypedDict]]
54
+ r"""List of tools which are available to the model during the conversation."""
54
55
  completion_args: NotRequired[Nullable[CompletionArgsTypedDict]]
55
56
  name: NotRequired[Nullable[str]]
56
57
  description: NotRequired[Nullable[str]]
58
+ metadata: NotRequired[Nullable[Dict[str, Any]]]
57
59
  agent_id: NotRequired[Nullable[str]]
60
+ agent_version: NotRequired[Nullable[int]]
58
61
  model: NotRequired[Nullable[str]]
59
62
 
60
63
 
@@ -71,7 +74,8 @@ class ConversationStreamRequest(BaseModel):
71
74
 
72
75
  instructions: OptionalNullable[str] = UNSET
73
76
 
74
- tools: OptionalNullable[List[ConversationStreamRequestTools]] = UNSET
77
+ tools: Optional[List[ConversationStreamRequestTools]] = None
78
+ r"""List of tools which are available to the model during the conversation."""
75
79
 
76
80
  completion_args: OptionalNullable[CompletionArgs] = UNSET
77
81
 
@@ -79,8 +83,12 @@ class ConversationStreamRequest(BaseModel):
79
83
 
80
84
  description: OptionalNullable[str] = UNSET
81
85
 
86
+ metadata: OptionalNullable[Dict[str, Any]] = UNSET
87
+
82
88
  agent_id: OptionalNullable[str] = UNSET
83
89
 
90
+ agent_version: OptionalNullable[int] = UNSET
91
+
84
92
  model: OptionalNullable[str] = UNSET
85
93
 
86
94
  @model_serializer(mode="wrap")
@@ -94,18 +102,21 @@ class ConversationStreamRequest(BaseModel):
94
102
  "completion_args",
95
103
  "name",
96
104
  "description",
105
+ "metadata",
97
106
  "agent_id",
107
+ "agent_version",
98
108
  "model",
99
109
  ]
100
110
  nullable_fields = [
101
111
  "store",
102
112
  "handoff_execution",
103
113
  "instructions",
104
- "tools",
105
114
  "completion_args",
106
115
  "name",
107
116
  "description",
117
+ "metadata",
108
118
  "agent_id",
119
+ "agent_version",
109
120
  "model",
110
121
  ]
111
122
  null_default_fields = []
@@ -4,20 +4,21 @@ from __future__ import annotations
4
4
  from datetime import datetime
5
5
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
6
  from pydantic import model_serializer
7
+ from typing import Any, Dict
7
8
  from typing_extensions import NotRequired, TypedDict
8
9
 
9
10
 
10
11
  class DocumentOutTypedDict(TypedDict):
11
12
  id: str
12
13
  library_id: str
13
- hash: str
14
- mime_type: str
15
- extension: str
16
- size: int
14
+ hash: Nullable[str]
15
+ mime_type: Nullable[str]
16
+ extension: Nullable[str]
17
+ size: Nullable[int]
17
18
  name: str
18
19
  created_at: datetime
19
20
  processing_status: str
20
- uploaded_by_id: str
21
+ uploaded_by_id: Nullable[str]
21
22
  uploaded_by_type: str
22
23
  tokens_processing_total: int
23
24
  summary: NotRequired[Nullable[str]]
@@ -25,6 +26,8 @@ class DocumentOutTypedDict(TypedDict):
25
26
  number_of_pages: NotRequired[Nullable[int]]
26
27
  tokens_processing_main_content: NotRequired[Nullable[int]]
27
28
  tokens_processing_summary: NotRequired[Nullable[int]]
29
+ url: NotRequired[Nullable[str]]
30
+ attributes: NotRequired[Nullable[Dict[str, Any]]]
28
31
 
29
32
 
30
33
  class DocumentOut(BaseModel):
@@ -32,13 +35,13 @@ class DocumentOut(BaseModel):
32
35
 
33
36
  library_id: str
34
37
 
35
- hash: str
38
+ hash: Nullable[str]
36
39
 
37
- mime_type: str
40
+ mime_type: Nullable[str]
38
41
 
39
- extension: str
42
+ extension: Nullable[str]
40
43
 
41
- size: int
44
+ size: Nullable[int]
42
45
 
43
46
  name: str
44
47
 
@@ -46,7 +49,7 @@ class DocumentOut(BaseModel):
46
49
 
47
50
  processing_status: str
48
51
 
49
- uploaded_by_id: str
52
+ uploaded_by_id: Nullable[str]
50
53
 
51
54
  uploaded_by_type: str
52
55
 
@@ -62,6 +65,10 @@ class DocumentOut(BaseModel):
62
65
 
63
66
  tokens_processing_summary: OptionalNullable[int] = UNSET
64
67
 
68
+ url: OptionalNullable[str] = UNSET
69
+
70
+ attributes: OptionalNullable[Dict[str, Any]] = UNSET
71
+
65
72
  @model_serializer(mode="wrap")
66
73
  def serialize_model(self, handler):
67
74
  optional_fields = [
@@ -70,13 +77,22 @@ class DocumentOut(BaseModel):
70
77
  "number_of_pages",
71
78
  "tokens_processing_main_content",
72
79
  "tokens_processing_summary",
80
+ "url",
81
+ "attributes",
73
82
  ]
74
83
  nullable_fields = [
84
+ "hash",
85
+ "mime_type",
86
+ "extension",
87
+ "size",
75
88
  "summary",
76
89
  "last_processed_at",
77
90
  "number_of_pages",
91
+ "uploaded_by_id",
78
92
  "tokens_processing_main_content",
79
93
  "tokens_processing_summary",
94
+ "url",
95
+ "attributes",
80
96
  ]
81
97
  null_default_fields = []
82
98
 
@@ -1,22 +1,43 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
+ from datetime import datetime
4
5
  from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
5
6
  from pydantic import model_serializer
6
- from typing_extensions import NotRequired, TypedDict
7
+ from typing import Dict, List, Union
8
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
9
+
10
+
11
+ AttributesTypedDict = TypeAliasType(
12
+ "AttributesTypedDict",
13
+ Union[
14
+ bool, str, int, float, datetime, List[str], List[int], List[float], List[bool]
15
+ ],
16
+ )
17
+
18
+
19
+ Attributes = TypeAliasType(
20
+ "Attributes",
21
+ Union[
22
+ bool, str, int, float, datetime, List[str], List[int], List[float], List[bool]
23
+ ],
24
+ )
7
25
 
8
26
 
9
27
  class DocumentUpdateInTypedDict(TypedDict):
10
28
  name: NotRequired[Nullable[str]]
29
+ attributes: NotRequired[Nullable[Dict[str, AttributesTypedDict]]]
11
30
 
12
31
 
13
32
  class DocumentUpdateIn(BaseModel):
14
33
  name: OptionalNullable[str] = UNSET
15
34
 
35
+ attributes: OptionalNullable[Dict[str, Attributes]] = UNSET
36
+
16
37
  @model_serializer(mode="wrap")
17
38
  def serialize_model(self, handler):
18
- optional_fields = ["name"]
19
- nullable_fields = ["name"]
39
+ optional_fields = ["name", "attributes"]
40
+ nullable_fields = ["name", "attributes"]
20
41
  null_default_fields = []
21
42
 
22
43
  serialized = handler(self)
@@ -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
  ]
@@ -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