mistralai 1.0.0rc1__py3-none-any.whl → 1.0.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 (114) hide show
  1. mistralai/agents.py +434 -0
  2. mistralai/basesdk.py +43 -6
  3. mistralai/chat.py +29 -34
  4. mistralai/client.py +1 -1
  5. mistralai/embeddings.py +4 -4
  6. mistralai/files.py +10 -10
  7. mistralai/fim.py +17 -18
  8. mistralai/fine_tuning.py +10 -849
  9. mistralai/jobs.py +844 -0
  10. mistralai/models/__init__.py +6 -4
  11. mistralai/models/agentscompletionrequest.py +96 -0
  12. mistralai/models/agentscompletionstreamrequest.py +92 -0
  13. mistralai/models/assistantmessage.py +4 -9
  14. mistralai/models/chatcompletionchoice.py +4 -15
  15. mistralai/models/chatcompletionrequest.py +25 -30
  16. mistralai/models/chatcompletionstreamrequest.py +25 -30
  17. mistralai/models/completionresponsestreamchoice.py +4 -9
  18. mistralai/models/delete_model_v1_models_model_id_deleteop.py +2 -0
  19. mistralai/models/deltamessage.py +7 -12
  20. mistralai/models/detailedjobout.py +4 -9
  21. mistralai/models/embeddingrequest.py +12 -17
  22. mistralai/models/eventout.py +4 -9
  23. mistralai/models/fileschema.py +4 -9
  24. mistralai/models/fimcompletionrequest.py +19 -24
  25. mistralai/models/fimcompletionstreamrequest.py +19 -24
  26. mistralai/models/ftmodelout.py +4 -9
  27. mistralai/models/functioncall.py +9 -3
  28. mistralai/models/githubrepositoryin.py +4 -9
  29. mistralai/models/githubrepositoryout.py +4 -9
  30. mistralai/models/httpvalidationerror.py +1 -1
  31. mistralai/models/jobin.py +4 -9
  32. mistralai/models/jobmetadataout.py +4 -9
  33. mistralai/models/jobout.py +4 -9
  34. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +2 -0
  35. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +1 -59
  36. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +4 -9
  37. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +2 -0
  38. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +2 -0
  39. mistralai/models/legacyjobmetadataout.py +4 -9
  40. mistralai/models/metricout.py +4 -9
  41. mistralai/models/modelcard.py +4 -9
  42. mistralai/models/retrieve_model_v1_models_model_id_getop.py +2 -0
  43. mistralai/models/retrievefileout.py +4 -9
  44. mistralai/models/security.py +4 -4
  45. mistralai/models/systemmessage.py +6 -6
  46. mistralai/models/toolmessage.py +4 -9
  47. mistralai/models/trainingparameters.py +4 -9
  48. mistralai/models/trainingparametersin.py +4 -9
  49. mistralai/models/updateftmodelin.py +4 -9
  50. mistralai/models/uploadfileout.py +4 -9
  51. mistralai/models/usermessage.py +6 -6
  52. mistralai/models/validationerror.py +6 -6
  53. mistralai/models/wandbintegration.py +4 -9
  54. mistralai/models/wandbintegrationout.py +4 -9
  55. mistralai/models_.py +24 -24
  56. mistralai/sdk.py +14 -6
  57. mistralai/sdkconfiguration.py +5 -4
  58. mistralai/types/basemodel.py +10 -6
  59. mistralai/utils/__init__.py +4 -0
  60. mistralai/utils/eventstreaming.py +8 -9
  61. mistralai/utils/logger.py +16 -0
  62. mistralai/utils/retries.py +2 -2
  63. mistralai/utils/security.py +5 -2
  64. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/METADATA +153 -69
  65. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/RECORD +114 -107
  66. mistralai_azure/basesdk.py +42 -4
  67. mistralai_azure/chat.py +15 -20
  68. mistralai_azure/models/__init__.py +3 -3
  69. mistralai_azure/models/assistantmessage.py +4 -9
  70. mistralai_azure/models/chatcompletionchoice.py +4 -15
  71. mistralai_azure/models/chatcompletionrequest.py +21 -26
  72. mistralai_azure/models/chatcompletionstreamrequest.py +21 -26
  73. mistralai_azure/models/completionresponsestreamchoice.py +4 -9
  74. mistralai_azure/models/deltamessage.py +7 -12
  75. mistralai_azure/models/functioncall.py +9 -3
  76. mistralai_azure/models/httpvalidationerror.py +1 -1
  77. mistralai_azure/models/systemmessage.py +6 -6
  78. mistralai_azure/models/toolmessage.py +4 -9
  79. mistralai_azure/models/usermessage.py +6 -6
  80. mistralai_azure/models/validationerror.py +6 -6
  81. mistralai_azure/sdk.py +7 -2
  82. mistralai_azure/sdkconfiguration.py +5 -4
  83. mistralai_azure/types/basemodel.py +10 -6
  84. mistralai_azure/utils/__init__.py +4 -0
  85. mistralai_azure/utils/eventstreaming.py +8 -9
  86. mistralai_azure/utils/logger.py +16 -0
  87. mistralai_azure/utils/retries.py +2 -2
  88. mistralai_gcp/basesdk.py +42 -4
  89. mistralai_gcp/chat.py +12 -17
  90. mistralai_gcp/fim.py +12 -13
  91. mistralai_gcp/models/__init__.py +3 -3
  92. mistralai_gcp/models/assistantmessage.py +4 -9
  93. mistralai_gcp/models/chatcompletionchoice.py +4 -15
  94. mistralai_gcp/models/chatcompletionrequest.py +23 -28
  95. mistralai_gcp/models/chatcompletionstreamrequest.py +23 -28
  96. mistralai_gcp/models/completionresponsestreamchoice.py +4 -9
  97. mistralai_gcp/models/deltamessage.py +7 -12
  98. mistralai_gcp/models/fimcompletionrequest.py +19 -24
  99. mistralai_gcp/models/fimcompletionstreamrequest.py +19 -24
  100. mistralai_gcp/models/functioncall.py +9 -3
  101. mistralai_gcp/models/httpvalidationerror.py +1 -1
  102. mistralai_gcp/models/systemmessage.py +6 -6
  103. mistralai_gcp/models/toolmessage.py +4 -9
  104. mistralai_gcp/models/usermessage.py +6 -6
  105. mistralai_gcp/models/validationerror.py +6 -6
  106. mistralai_gcp/sdk.py +9 -0
  107. mistralai_gcp/sdkconfiguration.py +5 -4
  108. mistralai_gcp/types/basemodel.py +10 -6
  109. mistralai_gcp/utils/__init__.py +4 -0
  110. mistralai_gcp/utils/eventstreaming.py +8 -9
  111. mistralai_gcp/utils/logger.py +16 -0
  112. mistralai_gcp/utils/retries.py +2 -2
  113. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/LICENSE +0 -0
  114. {mistralai-1.0.0rc1.dist-info → mistralai-1.0.1.dist-info}/WHEEL +0 -0
@@ -8,6 +8,14 @@ from typing import List, TypedDict, Union
8
8
  from typing_extensions import Annotated, NotRequired
9
9
 
10
10
 
11
+ InputsTypedDict = Union[str, List[str]]
12
+ r"""Text to embed."""
13
+
14
+
15
+ Inputs = Union[str, List[str]]
16
+ r"""Text to embed."""
17
+
18
+
11
19
  class EmbeddingRequestTypedDict(TypedDict):
12
20
  inputs: InputsTypedDict
13
21
  r"""Text to embed."""
@@ -39,28 +47,15 @@ class EmbeddingRequest(BaseModel):
39
47
  k = f.alias or n
40
48
  val = serialized.get(k)
41
49
 
50
+ optional_nullable = k in optional_fields and k in nullable_fields
51
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
52
+
42
53
  if val is not None and val != UNSET_SENTINEL:
43
54
  m[k] = val
44
55
  elif val != UNSET_SENTINEL and (
45
- not k in optional_fields
46
- or (
47
- k in optional_fields
48
- and k in nullable_fields
49
- and (
50
- self.__pydantic_fields_set__.intersection({n})
51
- or k in null_default_fields
52
- ) # pylint: disable=no-member
53
- )
56
+ not k in optional_fields or (optional_nullable and is_set)
54
57
  ):
55
58
  m[k] = val
56
59
 
57
60
  return m
58
61
 
59
-
60
- InputsTypedDict = Union[str, List[str]]
61
- r"""Text to embed."""
62
-
63
-
64
- Inputs = Union[str, List[str]]
65
- r"""Text to embed."""
66
-
@@ -36,18 +36,13 @@ class EventOut(BaseModel):
36
36
  k = f.alias or n
37
37
  val = serialized.get(k)
38
38
 
39
+ optional_nullable = k in optional_fields and k in nullable_fields
40
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
41
+
39
42
  if val is not None and val != UNSET_SENTINEL:
40
43
  m[k] = val
41
44
  elif val != UNSET_SENTINEL and (
42
- not k in optional_fields
43
- or (
44
- k in optional_fields
45
- and k in nullable_fields
46
- and (
47
- self.__pydantic_fields_set__.intersection({n})
48
- or k in null_default_fields
49
- ) # pylint: disable=no-member
50
- )
45
+ not k in optional_fields or (optional_nullable and is_set)
51
46
  ):
52
47
  m[k] = val
53
48
 
@@ -57,18 +57,13 @@ class FileSchema(BaseModel):
57
57
  k = f.alias or n
58
58
  val = serialized.get(k)
59
59
 
60
+ optional_nullable = k in optional_fields and k in nullable_fields
61
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
62
+
60
63
  if val is not None and val != UNSET_SENTINEL:
61
64
  m[k] = val
62
65
  elif val != UNSET_SENTINEL and (
63
- not k in optional_fields
64
- or (
65
- k in optional_fields
66
- and k in nullable_fields
67
- and (
68
- self.__pydantic_fields_set__.intersection({n})
69
- or k in null_default_fields
70
- ) # pylint: disable=no-member
71
- )
66
+ not k in optional_fields or (optional_nullable and is_set)
72
67
  ):
73
68
  m[k] = val
74
69
 
@@ -7,14 +7,22 @@ from typing import List, Optional, TypedDict, Union
7
7
  from typing_extensions import NotRequired
8
8
 
9
9
 
10
+ FIMCompletionRequestStopTypedDict = Union[str, List[str]]
11
+ r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
12
+
13
+
14
+ FIMCompletionRequestStop = Union[str, List[str]]
15
+ r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
16
+
17
+
10
18
  class FIMCompletionRequestTypedDict(TypedDict):
11
- prompt: str
12
- r"""The text/code to complete."""
13
- model: NotRequired[Nullable[str]]
19
+ model: Nullable[str]
14
20
  r"""ID of the model to use. Only compatible for now with:
15
21
  - `codestral-2405`
16
22
  - `codestral-latest`
17
23
  """
24
+ prompt: str
25
+ r"""The text/code to complete."""
18
26
  temperature: NotRequired[float]
19
27
  r"""What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both."""
20
28
  top_p: NotRequired[float]
@@ -34,13 +42,13 @@ class FIMCompletionRequestTypedDict(TypedDict):
34
42
 
35
43
 
36
44
  class FIMCompletionRequest(BaseModel):
37
- prompt: str
38
- r"""The text/code to complete."""
39
- model: OptionalNullable[str] = UNSET
45
+ model: Nullable[str]
40
46
  r"""ID of the model to use. Only compatible for now with:
41
47
  - `codestral-2405`
42
48
  - `codestral-latest`
43
49
  """
50
+ prompt: str
51
+ r"""The text/code to complete."""
44
52
  temperature: Optional[float] = 0.7
45
53
  r"""What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both."""
46
54
  top_p: Optional[float] = 1
@@ -60,7 +68,7 @@ class FIMCompletionRequest(BaseModel):
60
68
 
61
69
  @model_serializer(mode="wrap")
62
70
  def serialize_model(self, handler):
63
- optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "suffix"]
71
+ optional_fields = ["temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "suffix"]
64
72
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "suffix"]
65
73
  null_default_fields = []
66
74
 
@@ -72,28 +80,15 @@ class FIMCompletionRequest(BaseModel):
72
80
  k = f.alias or n
73
81
  val = serialized.get(k)
74
82
 
83
+ optional_nullable = k in optional_fields and k in nullable_fields
84
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
85
+
75
86
  if val is not None and val != UNSET_SENTINEL:
76
87
  m[k] = val
77
88
  elif val != UNSET_SENTINEL and (
78
- not k in optional_fields
79
- or (
80
- k in optional_fields
81
- and k in nullable_fields
82
- and (
83
- self.__pydantic_fields_set__.intersection({n})
84
- or k in null_default_fields
85
- ) # pylint: disable=no-member
86
- )
89
+ not k in optional_fields or (optional_nullable and is_set)
87
90
  ):
88
91
  m[k] = val
89
92
 
90
93
  return m
91
94
 
92
-
93
- FIMCompletionRequestStopTypedDict = Union[str, List[str]]
94
- r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
95
-
96
-
97
- FIMCompletionRequestStop = Union[str, List[str]]
98
- r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
99
-
@@ -7,14 +7,22 @@ from typing import List, Optional, TypedDict, Union
7
7
  from typing_extensions import NotRequired
8
8
 
9
9
 
10
+ FIMCompletionStreamRequestStopTypedDict = Union[str, List[str]]
11
+ r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
12
+
13
+
14
+ FIMCompletionStreamRequestStop = Union[str, List[str]]
15
+ r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
16
+
17
+
10
18
  class FIMCompletionStreamRequestTypedDict(TypedDict):
11
- prompt: str
12
- r"""The text/code to complete."""
13
- model: NotRequired[Nullable[str]]
19
+ model: Nullable[str]
14
20
  r"""ID of the model to use. Only compatible for now with:
15
21
  - `codestral-2405`
16
22
  - `codestral-latest`
17
23
  """
24
+ prompt: str
25
+ r"""The text/code to complete."""
18
26
  temperature: NotRequired[float]
19
27
  r"""What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both."""
20
28
  top_p: NotRequired[float]
@@ -33,13 +41,13 @@ class FIMCompletionStreamRequestTypedDict(TypedDict):
33
41
 
34
42
 
35
43
  class FIMCompletionStreamRequest(BaseModel):
36
- prompt: str
37
- r"""The text/code to complete."""
38
- model: OptionalNullable[str] = UNSET
44
+ model: Nullable[str]
39
45
  r"""ID of the model to use. Only compatible for now with:
40
46
  - `codestral-2405`
41
47
  - `codestral-latest`
42
48
  """
49
+ prompt: str
50
+ r"""The text/code to complete."""
43
51
  temperature: Optional[float] = 0.7
44
52
  r"""What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both."""
45
53
  top_p: Optional[float] = 1
@@ -58,7 +66,7 @@ class FIMCompletionStreamRequest(BaseModel):
58
66
 
59
67
  @model_serializer(mode="wrap")
60
68
  def serialize_model(self, handler):
61
- optional_fields = ["model", "temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "suffix"]
69
+ optional_fields = ["temperature", "top_p", "max_tokens", "min_tokens", "stream", "stop", "random_seed", "suffix"]
62
70
  nullable_fields = ["model", "max_tokens", "min_tokens", "random_seed", "suffix"]
63
71
  null_default_fields = []
64
72
 
@@ -70,28 +78,15 @@ class FIMCompletionStreamRequest(BaseModel):
70
78
  k = f.alias or n
71
79
  val = serialized.get(k)
72
80
 
81
+ optional_nullable = k in optional_fields and k in nullable_fields
82
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
83
+
73
84
  if val is not None and val != UNSET_SENTINEL:
74
85
  m[k] = val
75
86
  elif val != UNSET_SENTINEL and (
76
- not k in optional_fields
77
- or (
78
- k in optional_fields
79
- and k in nullable_fields
80
- and (
81
- self.__pydantic_fields_set__.intersection({n})
82
- or k in null_default_fields
83
- ) # pylint: disable=no-member
84
- )
87
+ not k in optional_fields or (optional_nullable and is_set)
85
88
  ):
86
89
  m[k] = val
87
90
 
88
91
  return m
89
92
 
90
-
91
- FIMCompletionStreamRequestStopTypedDict = Union[str, List[str]]
92
- r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
93
-
94
-
95
- FIMCompletionStreamRequestStop = Union[str, List[str]]
96
- r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""
97
-
@@ -51,18 +51,13 @@ class FTModelOut(BaseModel):
51
51
  k = f.alias or n
52
52
  val = serialized.get(k)
53
53
 
54
+ optional_nullable = k in optional_fields and k in nullable_fields
55
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
56
+
54
57
  if val is not None and val != UNSET_SENTINEL:
55
58
  m[k] = val
56
59
  elif val != UNSET_SENTINEL and (
57
- not k in optional_fields
58
- or (
59
- k in optional_fields
60
- and k in nullable_fields
61
- and (
62
- self.__pydantic_fields_set__.intersection({n})
63
- or k in null_default_fields
64
- ) # pylint: disable=no-member
65
- )
60
+ not k in optional_fields or (optional_nullable and is_set)
66
61
  ):
67
62
  m[k] = val
68
63
 
@@ -2,15 +2,21 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from mistralai.types import BaseModel
5
- from typing import TypedDict
5
+ from typing import Any, Dict, TypedDict, Union
6
+
7
+
8
+ ArgumentsTypedDict = Union[Dict[str, Any], str]
9
+
10
+
11
+ Arguments = Union[Dict[str, Any], str]
6
12
 
7
13
 
8
14
  class FunctionCallTypedDict(TypedDict):
9
15
  name: str
10
- arguments: str
16
+ arguments: ArgumentsTypedDict
11
17
 
12
18
 
13
19
  class FunctionCall(BaseModel):
14
20
  name: str
15
- arguments: str
21
+ arguments: Arguments
16
22
 
@@ -38,18 +38,13 @@ class GithubRepositoryIn(BaseModel):
38
38
  k = f.alias or n
39
39
  val = serialized.get(k)
40
40
 
41
+ optional_nullable = k in optional_fields and k in nullable_fields
42
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
43
+
41
44
  if val is not None and val != UNSET_SENTINEL:
42
45
  m[k] = val
43
46
  elif val != UNSET_SENTINEL and (
44
- not k in optional_fields
45
- or (
46
- k in optional_fields
47
- and k in nullable_fields
48
- and (
49
- self.__pydantic_fields_set__.intersection({n})
50
- or k in null_default_fields
51
- ) # pylint: disable=no-member
52
- )
47
+ not k in optional_fields or (optional_nullable and is_set)
53
48
  ):
54
49
  m[k] = val
55
50
 
@@ -38,18 +38,13 @@ class GithubRepositoryOut(BaseModel):
38
38
  k = f.alias or n
39
39
  val = serialized.get(k)
40
40
 
41
+ optional_nullable = k in optional_fields and k in nullable_fields
42
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
43
+
41
44
  if val is not None and val != UNSET_SENTINEL:
42
45
  m[k] = val
43
46
  elif val != UNSET_SENTINEL and (
44
- not k in optional_fields
45
- or (
46
- k in optional_fields
47
- and k in nullable_fields
48
- and (
49
- self.__pydantic_fields_set__.intersection({n})
50
- or k in null_default_fields
51
- ) # pylint: disable=no-member
52
- )
47
+ not k in optional_fields or (optional_nullable and is_set)
53
48
  ):
54
49
  m[k] = val
55
50
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  from __future__ import annotations
4
4
  from .validationerror import ValidationError
5
+ from mistralai import utils
5
6
  from mistralai.types import BaseModel
6
- import mistralai.utils as utils
7
7
  from typing import List, Optional
8
8
 
9
9
  class HTTPValidationErrorData(BaseModel):
mistralai/models/jobin.py CHANGED
@@ -59,18 +59,13 @@ class JobIn(BaseModel):
59
59
  k = f.alias or n
60
60
  val = serialized.get(k)
61
61
 
62
+ optional_nullable = k in optional_fields and k in nullable_fields
63
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
64
+
62
65
  if val is not None and val != UNSET_SENTINEL:
63
66
  m[k] = val
64
67
  elif val != UNSET_SENTINEL and (
65
- not k in optional_fields
66
- or (
67
- k in optional_fields
68
- and k in nullable_fields
69
- and (
70
- self.__pydantic_fields_set__.intersection({n})
71
- or k in null_default_fields
72
- ) # pylint: disable=no-member
73
- )
68
+ not k in optional_fields or (optional_nullable and is_set)
74
69
  ):
75
70
  m[k] = val
76
71
 
@@ -40,18 +40,13 @@ class JobMetadataOut(BaseModel):
40
40
  k = f.alias or n
41
41
  val = serialized.get(k)
42
42
 
43
+ optional_nullable = k in optional_fields and k in nullable_fields
44
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
45
+
43
46
  if val is not None and val != UNSET_SENTINEL:
44
47
  m[k] = val
45
48
  elif val != UNSET_SENTINEL and (
46
- not k in optional_fields
47
- or (
48
- k in optional_fields
49
- and k in nullable_fields
50
- and (
51
- self.__pydantic_fields_set__.intersection({n})
52
- or k in null_default_fields
53
- ) # pylint: disable=no-member
54
- )
49
+ not k in optional_fields or (optional_nullable and is_set)
55
50
  ):
56
51
  m[k] = val
57
52
 
@@ -93,18 +93,13 @@ class JobOut(BaseModel):
93
93
  k = f.alias or n
94
94
  val = serialized.get(k)
95
95
 
96
+ optional_nullable = k in optional_fields and k in nullable_fields
97
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
98
+
96
99
  if val is not None and val != UNSET_SENTINEL:
97
100
  m[k] = val
98
101
  elif val != UNSET_SENTINEL and (
99
- not k in optional_fields
100
- or (
101
- k in optional_fields
102
- and k in nullable_fields
103
- and (
104
- self.__pydantic_fields_set__.intersection({n})
105
- or k in null_default_fields
106
- ) # pylint: disable=no-member
107
- )
102
+ not k in optional_fields or (optional_nullable and is_set)
108
103
  ):
109
104
  m[k] = val
110
105
 
@@ -9,8 +9,10 @@ from typing_extensions import Annotated
9
9
 
10
10
  class JobsAPIRoutesFineTuningArchiveFineTunedModelRequestTypedDict(TypedDict):
11
11
  model_id: str
12
+ r"""The ID of the model to archive."""
12
13
 
13
14
 
14
15
  class JobsAPIRoutesFineTuningArchiveFineTunedModelRequest(BaseModel):
15
16
  model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
17
+ r"""The ID of the model to archive."""
16
18
 
@@ -1,69 +1,11 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
3
  from __future__ import annotations
4
- from .jobin import JobIn, JobInTypedDict
5
4
  from .jobout import JobOut, JobOutTypedDict
6
5
  from .legacyjobmetadataout import LegacyJobMetadataOut, LegacyJobMetadataOutTypedDict
7
- from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
8
- from mistralai.utils import FieldMetadata, QueryParamMetadata, RequestMetadata
9
- from pydantic import model_serializer
10
- from typing import TypedDict, Union
11
- from typing_extensions import Annotated, NotRequired
6
+ from typing import Union
12
7
 
13
8
 
14
- class JobsAPIRoutesFineTuningCreateFineTuningJobRequestTypedDict(TypedDict):
15
- job_in: JobInTypedDict
16
- dry_run: NotRequired[Nullable[bool]]
17
- r"""* If `true` the job is not spawned, instead the query returns a handful of useful metadata
18
- for the user to perform sanity checks (see `LegacyJobMetadataOut` response).
19
- * Otherwise, the job is started and the query returns the job ID along with some of the
20
- input parameters (see `JobOut` response).
21
-
22
- """
23
-
24
-
25
- class JobsAPIRoutesFineTuningCreateFineTuningJobRequest(BaseModel):
26
- job_in: Annotated[JobIn, FieldMetadata(request=RequestMetadata(media_type="application/json"))]
27
- dry_run: Annotated[OptionalNullable[bool], FieldMetadata(query=QueryParamMetadata(style="form", explode=True))] = UNSET
28
- r"""* If `true` the job is not spawned, instead the query returns a handful of useful metadata
29
- for the user to perform sanity checks (see `LegacyJobMetadataOut` response).
30
- * Otherwise, the job is started and the query returns the job ID along with some of the
31
- input parameters (see `JobOut` response).
32
-
33
- """
34
-
35
- @model_serializer(mode="wrap")
36
- def serialize_model(self, handler):
37
- optional_fields = ["dry_run"]
38
- nullable_fields = ["dry_run"]
39
- null_default_fields = []
40
-
41
- serialized = handler(self)
42
-
43
- m = {}
44
-
45
- for n, f in self.model_fields.items():
46
- k = f.alias or n
47
- val = serialized.get(k)
48
-
49
- if val is not None and val != UNSET_SENTINEL:
50
- m[k] = val
51
- elif val != UNSET_SENTINEL and (
52
- not k in optional_fields
53
- or (
54
- k in optional_fields
55
- and k in nullable_fields
56
- and (
57
- self.__pydantic_fields_set__.intersection({n})
58
- or k in null_default_fields
59
- ) # pylint: disable=no-member
60
- )
61
- ):
62
- m[k] = val
63
-
64
- return m
65
-
66
-
67
9
  JobsAPIRoutesFineTuningCreateFineTuningJobResponseTypedDict = Union[LegacyJobMetadataOutTypedDict, JobOutTypedDict]
68
10
  r"""OK"""
69
11
 
@@ -67,18 +67,13 @@ class JobsAPIRoutesFineTuningGetFineTuningJobsRequest(BaseModel):
67
67
  k = f.alias or n
68
68
  val = serialized.get(k)
69
69
 
70
+ optional_nullable = k in optional_fields and k in nullable_fields
71
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
72
+
70
73
  if val is not None and val != UNSET_SENTINEL:
71
74
  m[k] = val
72
75
  elif val != UNSET_SENTINEL and (
73
- not k in optional_fields
74
- or (
75
- k in optional_fields
76
- and k in nullable_fields
77
- and (
78
- self.__pydantic_fields_set__.intersection({n})
79
- or k in null_default_fields
80
- ) # pylint: disable=no-member
81
- )
76
+ not k in optional_fields or (optional_nullable and is_set)
82
77
  ):
83
78
  m[k] = val
84
79
 
@@ -9,8 +9,10 @@ from typing_extensions import Annotated
9
9
 
10
10
  class JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequestTypedDict(TypedDict):
11
11
  model_id: str
12
+ r"""The ID of the model to unarchive."""
12
13
 
13
14
 
14
15
  class JobsAPIRoutesFineTuningUnarchiveFineTunedModelRequest(BaseModel):
15
16
  model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
17
+ r"""The ID of the model to unarchive."""
16
18
 
@@ -10,10 +10,12 @@ from typing_extensions import Annotated
10
10
 
11
11
  class JobsAPIRoutesFineTuningUpdateFineTunedModelRequestTypedDict(TypedDict):
12
12
  model_id: str
13
+ r"""The ID of the model to update."""
13
14
  update_ft_model_in: UpdateFTModelInTypedDict
14
15
 
15
16
 
16
17
  class JobsAPIRoutesFineTuningUpdateFineTunedModelRequest(BaseModel):
17
18
  model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
19
+ r"""The ID of the model to update."""
18
20
  update_ft_model_in: Annotated[UpdateFTModelIn, FieldMetadata(request=RequestMetadata(media_type="application/json"))]
19
21
 
@@ -66,18 +66,13 @@ class LegacyJobMetadataOut(BaseModel):
66
66
  k = f.alias or n
67
67
  val = serialized.get(k)
68
68
 
69
+ optional_nullable = k in optional_fields and k in nullable_fields
70
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
71
+
69
72
  if val is not None and val != UNSET_SENTINEL:
70
73
  m[k] = val
71
74
  elif val != UNSET_SENTINEL and (
72
- not k in optional_fields
73
- or (
74
- k in optional_fields
75
- and k in nullable_fields
76
- and (
77
- self.__pydantic_fields_set__.intersection({n})
78
- or k in null_default_fields
79
- ) # pylint: disable=no-member
80
- )
75
+ not k in optional_fields or (optional_nullable and is_set)
81
76
  ):
82
77
  m[k] = val
83
78
 
@@ -36,18 +36,13 @@ class MetricOut(BaseModel):
36
36
  k = f.alias or n
37
37
  val = serialized.get(k)
38
38
 
39
+ optional_nullable = k in optional_fields and k in nullable_fields
40
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
41
+
39
42
  if val is not None and val != UNSET_SENTINEL:
40
43
  m[k] = val
41
44
  elif val != UNSET_SENTINEL and (
42
- not k in optional_fields
43
- or (
44
- k in optional_fields
45
- and k in nullable_fields
46
- and (
47
- self.__pydantic_fields_set__.intersection({n})
48
- or k in null_default_fields
49
- ) # pylint: disable=no-member
50
- )
45
+ not k in optional_fields or (optional_nullable and is_set)
51
46
  ):
52
47
  m[k] = val
53
48
 
@@ -52,18 +52,13 @@ class ModelCard(BaseModel):
52
52
  k = f.alias or n
53
53
  val = serialized.get(k)
54
54
 
55
+ optional_nullable = k in optional_fields and k in nullable_fields
56
+ is_set = (self.__pydantic_fields_set__.intersection({n}) or k in null_default_fields) # pylint: disable=no-member
57
+
55
58
  if val is not None and val != UNSET_SENTINEL:
56
59
  m[k] = val
57
60
  elif val != UNSET_SENTINEL and (
58
- not k in optional_fields
59
- or (
60
- k in optional_fields
61
- and k in nullable_fields
62
- and (
63
- self.__pydantic_fields_set__.intersection({n})
64
- or k in null_default_fields
65
- ) # pylint: disable=no-member
66
- )
61
+ not k in optional_fields or (optional_nullable and is_set)
67
62
  ):
68
63
  m[k] = val
69
64
 
@@ -9,8 +9,10 @@ from typing_extensions import Annotated
9
9
 
10
10
  class RetrieveModelV1ModelsModelIDGetRequestTypedDict(TypedDict):
11
11
  model_id: str
12
+ r"""The ID of the model to retrieve."""
12
13
 
13
14
 
14
15
  class RetrieveModelV1ModelsModelIDGetRequest(BaseModel):
15
16
  model_id: Annotated[str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))]
17
+ r"""The ID of the model to retrieve."""
16
18