mistralai 1.7.1__py3-none-any.whl → 1.8.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 (91) hide show
  1. mistralai/_version.py +2 -2
  2. mistralai/beta.py +22 -0
  3. mistralai/conversations.py +2660 -0
  4. mistralai/embeddings.py +12 -0
  5. mistralai/extra/__init__.py +10 -2
  6. mistralai/extra/exceptions.py +14 -0
  7. mistralai/extra/mcp/__init__.py +0 -0
  8. mistralai/extra/mcp/auth.py +166 -0
  9. mistralai/extra/mcp/base.py +155 -0
  10. mistralai/extra/mcp/sse.py +165 -0
  11. mistralai/extra/mcp/stdio.py +22 -0
  12. mistralai/extra/run/__init__.py +0 -0
  13. mistralai/extra/run/context.py +295 -0
  14. mistralai/extra/run/result.py +212 -0
  15. mistralai/extra/run/tools.py +225 -0
  16. mistralai/extra/run/utils.py +36 -0
  17. mistralai/extra/tests/test_struct_chat.py +1 -1
  18. mistralai/mistral_agents.py +1160 -0
  19. mistralai/models/__init__.py +472 -1
  20. mistralai/models/agent.py +129 -0
  21. mistralai/models/agentconversation.py +71 -0
  22. mistralai/models/agentcreationrequest.py +109 -0
  23. mistralai/models/agenthandoffdoneevent.py +33 -0
  24. mistralai/models/agenthandoffentry.py +75 -0
  25. mistralai/models/agenthandoffstartedevent.py +33 -0
  26. mistralai/models/agents_api_v1_agents_getop.py +16 -0
  27. mistralai/models/agents_api_v1_agents_listop.py +24 -0
  28. mistralai/models/agents_api_v1_agents_update_versionop.py +21 -0
  29. mistralai/models/agents_api_v1_agents_updateop.py +23 -0
  30. mistralai/models/agents_api_v1_conversations_append_streamop.py +28 -0
  31. mistralai/models/agents_api_v1_conversations_appendop.py +28 -0
  32. mistralai/models/agents_api_v1_conversations_getop.py +33 -0
  33. mistralai/models/agents_api_v1_conversations_historyop.py +16 -0
  34. mistralai/models/agents_api_v1_conversations_listop.py +37 -0
  35. mistralai/models/agents_api_v1_conversations_messagesop.py +16 -0
  36. mistralai/models/agents_api_v1_conversations_restart_streamop.py +26 -0
  37. mistralai/models/agents_api_v1_conversations_restartop.py +26 -0
  38. mistralai/models/agentupdaterequest.py +111 -0
  39. mistralai/models/builtinconnectors.py +13 -0
  40. mistralai/models/chatcompletionresponse.py +6 -6
  41. mistralai/models/codeinterpretertool.py +17 -0
  42. mistralai/models/completionargs.py +100 -0
  43. mistralai/models/completionargsstop.py +13 -0
  44. mistralai/models/completionjobout.py +3 -3
  45. mistralai/models/conversationappendrequest.py +35 -0
  46. mistralai/models/conversationappendstreamrequest.py +37 -0
  47. mistralai/models/conversationevents.py +72 -0
  48. mistralai/models/conversationhistory.py +58 -0
  49. mistralai/models/conversationinputs.py +14 -0
  50. mistralai/models/conversationmessages.py +28 -0
  51. mistralai/models/conversationrequest.py +133 -0
  52. mistralai/models/conversationresponse.py +51 -0
  53. mistralai/models/conversationrestartrequest.py +42 -0
  54. mistralai/models/conversationrestartstreamrequest.py +44 -0
  55. mistralai/models/conversationstreamrequest.py +135 -0
  56. mistralai/models/conversationusageinfo.py +63 -0
  57. mistralai/models/documentlibrarytool.py +22 -0
  58. mistralai/models/embeddingdtype.py +7 -0
  59. mistralai/models/embeddingrequest.py +43 -3
  60. mistralai/models/fimcompletionresponse.py +6 -6
  61. mistralai/models/functioncallentry.py +76 -0
  62. mistralai/models/functioncallentryarguments.py +15 -0
  63. mistralai/models/functioncallevent.py +36 -0
  64. mistralai/models/functionresultentry.py +69 -0
  65. mistralai/models/functiontool.py +21 -0
  66. mistralai/models/imagegenerationtool.py +17 -0
  67. mistralai/models/inputentries.py +18 -0
  68. mistralai/models/messageentries.py +18 -0
  69. mistralai/models/messageinputcontentchunks.py +26 -0
  70. mistralai/models/messageinputentry.py +89 -0
  71. mistralai/models/messageoutputcontentchunks.py +30 -0
  72. mistralai/models/messageoutputentry.py +100 -0
  73. mistralai/models/messageoutputevent.py +93 -0
  74. mistralai/models/modelconversation.py +127 -0
  75. mistralai/models/outputcontentchunks.py +30 -0
  76. mistralai/models/responsedoneevent.py +25 -0
  77. mistralai/models/responseerrorevent.py +27 -0
  78. mistralai/models/responsestartedevent.py +24 -0
  79. mistralai/models/ssetypes.py +18 -0
  80. mistralai/models/toolexecutiondoneevent.py +34 -0
  81. mistralai/models/toolexecutionentry.py +70 -0
  82. mistralai/models/toolexecutionstartedevent.py +31 -0
  83. mistralai/models/toolfilechunk.py +61 -0
  84. mistralai/models/toolreferencechunk.py +61 -0
  85. mistralai/models/websearchpremiumtool.py +17 -0
  86. mistralai/models/websearchtool.py +17 -0
  87. mistralai/sdk.py +3 -0
  88. {mistralai-1.7.1.dist-info → mistralai-1.8.1.dist-info}/METADATA +42 -7
  89. {mistralai-1.7.1.dist-info → mistralai-1.8.1.dist-info}/RECORD +91 -14
  90. {mistralai-1.7.1.dist-info → mistralai-1.8.1.dist-info}/LICENSE +0 -0
  91. {mistralai-1.7.1.dist-info → mistralai-1.8.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,36 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from datetime import datetime
5
+ from mistralai.types import BaseModel
6
+ from typing import Literal, Optional
7
+ from typing_extensions import NotRequired, TypedDict
8
+
9
+
10
+ FunctionCallEventType = Literal["function.call.delta"]
11
+
12
+
13
+ class FunctionCallEventTypedDict(TypedDict):
14
+ id: str
15
+ name: str
16
+ tool_call_id: str
17
+ arguments: str
18
+ type: NotRequired[FunctionCallEventType]
19
+ created_at: NotRequired[datetime]
20
+ output_index: NotRequired[int]
21
+
22
+
23
+ class FunctionCallEvent(BaseModel):
24
+ id: str
25
+
26
+ name: str
27
+
28
+ tool_call_id: str
29
+
30
+ arguments: str
31
+
32
+ type: Optional[FunctionCallEventType] = "function.call.delta"
33
+
34
+ created_at: Optional[datetime] = None
35
+
36
+ output_index: Optional[int] = 0
@@ -0,0 +1,69 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from datetime import datetime
5
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
+ from pydantic import model_serializer
7
+ from typing import Literal, Optional
8
+ from typing_extensions import NotRequired, TypedDict
9
+
10
+
11
+ FunctionResultEntryObject = Literal["entry"]
12
+
13
+ FunctionResultEntryType = Literal["function.result"]
14
+
15
+
16
+ class FunctionResultEntryTypedDict(TypedDict):
17
+ tool_call_id: str
18
+ result: str
19
+ object: NotRequired[FunctionResultEntryObject]
20
+ type: NotRequired[FunctionResultEntryType]
21
+ created_at: NotRequired[datetime]
22
+ completed_at: NotRequired[Nullable[datetime]]
23
+ id: NotRequired[str]
24
+
25
+
26
+ class FunctionResultEntry(BaseModel):
27
+ tool_call_id: str
28
+
29
+ result: str
30
+
31
+ object: Optional[FunctionResultEntryObject] = "entry"
32
+
33
+ type: Optional[FunctionResultEntryType] = "function.result"
34
+
35
+ created_at: Optional[datetime] = None
36
+
37
+ completed_at: OptionalNullable[datetime] = UNSET
38
+
39
+ id: Optional[str] = None
40
+
41
+ @model_serializer(mode="wrap")
42
+ def serialize_model(self, handler):
43
+ optional_fields = ["object", "type", "created_at", "completed_at", "id"]
44
+ nullable_fields = ["completed_at"]
45
+ null_default_fields = []
46
+
47
+ serialized = handler(self)
48
+
49
+ m = {}
50
+
51
+ for n, f in self.model_fields.items():
52
+ k = f.alias or n
53
+ val = serialized.get(k)
54
+ serialized.pop(k, None)
55
+
56
+ optional_nullable = k in optional_fields and k in nullable_fields
57
+ is_set = (
58
+ self.__pydantic_fields_set__.intersection({n})
59
+ or k in null_default_fields
60
+ ) # pylint: disable=no-member
61
+
62
+ if val is not None and val != UNSET_SENTINEL:
63
+ m[k] = val
64
+ elif val != UNSET_SENTINEL and (
65
+ not k in optional_fields or (optional_nullable and is_set)
66
+ ):
67
+ m[k] = val
68
+
69
+ return m
@@ -0,0 +1,21 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .function import Function, FunctionTypedDict
5
+ from mistralai.types import BaseModel
6
+ from typing import Literal, Optional
7
+ from typing_extensions import NotRequired, TypedDict
8
+
9
+
10
+ FunctionToolType = Literal["function"]
11
+
12
+
13
+ class FunctionToolTypedDict(TypedDict):
14
+ function: FunctionTypedDict
15
+ type: NotRequired[FunctionToolType]
16
+
17
+
18
+ class FunctionTool(BaseModel):
19
+ function: Function
20
+
21
+ type: Optional[FunctionToolType] = "function"
@@ -0,0 +1,17 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from mistralai.types import BaseModel
5
+ from typing import Literal, Optional
6
+ from typing_extensions import NotRequired, TypedDict
7
+
8
+
9
+ ImageGenerationToolType = Literal["image_generation"]
10
+
11
+
12
+ class ImageGenerationToolTypedDict(TypedDict):
13
+ type: NotRequired[ImageGenerationToolType]
14
+
15
+
16
+ class ImageGenerationTool(BaseModel):
17
+ type: Optional[ImageGenerationToolType] = "image_generation"
@@ -0,0 +1,18 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .functionresultentry import FunctionResultEntry, FunctionResultEntryTypedDict
5
+ from .messageinputentry import MessageInputEntry, MessageInputEntryTypedDict
6
+ from typing import Union
7
+ from typing_extensions import TypeAliasType
8
+
9
+
10
+ InputEntriesTypedDict = TypeAliasType(
11
+ "InputEntriesTypedDict",
12
+ Union[MessageInputEntryTypedDict, FunctionResultEntryTypedDict],
13
+ )
14
+
15
+
16
+ InputEntries = TypeAliasType(
17
+ "InputEntries", Union[MessageInputEntry, FunctionResultEntry]
18
+ )
@@ -0,0 +1,18 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .messageinputentry import MessageInputEntry, MessageInputEntryTypedDict
5
+ from .messageoutputentry import MessageOutputEntry, MessageOutputEntryTypedDict
6
+ from typing import Union
7
+ from typing_extensions import TypeAliasType
8
+
9
+
10
+ MessageEntriesTypedDict = TypeAliasType(
11
+ "MessageEntriesTypedDict",
12
+ Union[MessageInputEntryTypedDict, MessageOutputEntryTypedDict],
13
+ )
14
+
15
+
16
+ MessageEntries = TypeAliasType(
17
+ "MessageEntries", Union[MessageInputEntry, MessageOutputEntry]
18
+ )
@@ -0,0 +1,26 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .documenturlchunk import DocumentURLChunk, DocumentURLChunkTypedDict
5
+ from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
6
+ from .textchunk import TextChunk, TextChunkTypedDict
7
+ from .toolfilechunk import ToolFileChunk, ToolFileChunkTypedDict
8
+ from typing import Union
9
+ from typing_extensions import TypeAliasType
10
+
11
+
12
+ MessageInputContentChunksTypedDict = TypeAliasType(
13
+ "MessageInputContentChunksTypedDict",
14
+ Union[
15
+ TextChunkTypedDict,
16
+ ImageURLChunkTypedDict,
17
+ DocumentURLChunkTypedDict,
18
+ ToolFileChunkTypedDict,
19
+ ],
20
+ )
21
+
22
+
23
+ MessageInputContentChunks = TypeAliasType(
24
+ "MessageInputContentChunks",
25
+ Union[TextChunk, ImageURLChunk, DocumentURLChunk, ToolFileChunk],
26
+ )
@@ -0,0 +1,89 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .messageinputcontentchunks import (
5
+ MessageInputContentChunks,
6
+ MessageInputContentChunksTypedDict,
7
+ )
8
+ from datetime import datetime
9
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
10
+ from pydantic import model_serializer
11
+ from typing import List, Literal, Optional, Union
12
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
13
+
14
+
15
+ Object = Literal["entry"]
16
+
17
+ MessageInputEntryType = Literal["message.input"]
18
+
19
+ MessageInputEntryRole = Literal["assistant", "user"]
20
+
21
+ MessageInputEntryContentTypedDict = TypeAliasType(
22
+ "MessageInputEntryContentTypedDict",
23
+ Union[str, List[MessageInputContentChunksTypedDict]],
24
+ )
25
+
26
+
27
+ MessageInputEntryContent = TypeAliasType(
28
+ "MessageInputEntryContent", Union[str, List[MessageInputContentChunks]]
29
+ )
30
+
31
+
32
+ class MessageInputEntryTypedDict(TypedDict):
33
+ r"""Representation of an input message inside the conversation."""
34
+
35
+ role: MessageInputEntryRole
36
+ content: MessageInputEntryContentTypedDict
37
+ object: NotRequired[Object]
38
+ type: NotRequired[MessageInputEntryType]
39
+ created_at: NotRequired[datetime]
40
+ completed_at: NotRequired[Nullable[datetime]]
41
+ id: NotRequired[str]
42
+
43
+
44
+ class MessageInputEntry(BaseModel):
45
+ r"""Representation of an input message inside the conversation."""
46
+
47
+ role: MessageInputEntryRole
48
+
49
+ content: MessageInputEntryContent
50
+
51
+ object: Optional[Object] = "entry"
52
+
53
+ type: Optional[MessageInputEntryType] = "message.input"
54
+
55
+ created_at: Optional[datetime] = None
56
+
57
+ completed_at: OptionalNullable[datetime] = UNSET
58
+
59
+ id: Optional[str] = None
60
+
61
+ @model_serializer(mode="wrap")
62
+ def serialize_model(self, handler):
63
+ optional_fields = ["object", "type", "created_at", "completed_at", "id"]
64
+ nullable_fields = ["completed_at"]
65
+ null_default_fields = []
66
+
67
+ serialized = handler(self)
68
+
69
+ m = {}
70
+
71
+ for n, f in self.model_fields.items():
72
+ k = f.alias or n
73
+ val = serialized.get(k)
74
+ serialized.pop(k, None)
75
+
76
+ optional_nullable = k in optional_fields and k in nullable_fields
77
+ is_set = (
78
+ self.__pydantic_fields_set__.intersection({n})
79
+ or k in null_default_fields
80
+ ) # pylint: disable=no-member
81
+
82
+ if val is not None and val != UNSET_SENTINEL:
83
+ m[k] = val
84
+ elif val != UNSET_SENTINEL and (
85
+ not k in optional_fields or (optional_nullable and is_set)
86
+ ):
87
+ m[k] = val
88
+
89
+ return m
@@ -0,0 +1,30 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .documenturlchunk import DocumentURLChunk, DocumentURLChunkTypedDict
5
+ from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
6
+ from .textchunk import TextChunk, TextChunkTypedDict
7
+ from .toolfilechunk import ToolFileChunk, ToolFileChunkTypedDict
8
+ from .toolreferencechunk import ToolReferenceChunk, ToolReferenceChunkTypedDict
9
+ from typing import Union
10
+ from typing_extensions import TypeAliasType
11
+
12
+
13
+ MessageOutputContentChunksTypedDict = TypeAliasType(
14
+ "MessageOutputContentChunksTypedDict",
15
+ Union[
16
+ TextChunkTypedDict,
17
+ ImageURLChunkTypedDict,
18
+ DocumentURLChunkTypedDict,
19
+ ToolFileChunkTypedDict,
20
+ ToolReferenceChunkTypedDict,
21
+ ],
22
+ )
23
+
24
+
25
+ MessageOutputContentChunks = TypeAliasType(
26
+ "MessageOutputContentChunks",
27
+ Union[
28
+ TextChunk, ImageURLChunk, DocumentURLChunk, ToolFileChunk, ToolReferenceChunk
29
+ ],
30
+ )
@@ -0,0 +1,100 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .messageoutputcontentchunks import (
5
+ MessageOutputContentChunks,
6
+ MessageOutputContentChunksTypedDict,
7
+ )
8
+ from datetime import datetime
9
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
10
+ from pydantic import model_serializer
11
+ from typing import List, Literal, Optional, Union
12
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
13
+
14
+
15
+ MessageOutputEntryObject = Literal["entry"]
16
+
17
+ MessageOutputEntryType = Literal["message.output"]
18
+
19
+ MessageOutputEntryRole = Literal["assistant"]
20
+
21
+ MessageOutputEntryContentTypedDict = TypeAliasType(
22
+ "MessageOutputEntryContentTypedDict",
23
+ Union[str, List[MessageOutputContentChunksTypedDict]],
24
+ )
25
+
26
+
27
+ MessageOutputEntryContent = TypeAliasType(
28
+ "MessageOutputEntryContent", Union[str, List[MessageOutputContentChunks]]
29
+ )
30
+
31
+
32
+ class MessageOutputEntryTypedDict(TypedDict):
33
+ content: MessageOutputEntryContentTypedDict
34
+ object: NotRequired[MessageOutputEntryObject]
35
+ type: NotRequired[MessageOutputEntryType]
36
+ created_at: NotRequired[datetime]
37
+ completed_at: NotRequired[Nullable[datetime]]
38
+ id: NotRequired[str]
39
+ agent_id: NotRequired[Nullable[str]]
40
+ model: NotRequired[Nullable[str]]
41
+ role: NotRequired[MessageOutputEntryRole]
42
+
43
+
44
+ class MessageOutputEntry(BaseModel):
45
+ content: MessageOutputEntryContent
46
+
47
+ object: Optional[MessageOutputEntryObject] = "entry"
48
+
49
+ type: Optional[MessageOutputEntryType] = "message.output"
50
+
51
+ created_at: Optional[datetime] = None
52
+
53
+ completed_at: OptionalNullable[datetime] = UNSET
54
+
55
+ id: Optional[str] = None
56
+
57
+ agent_id: OptionalNullable[str] = UNSET
58
+
59
+ model: OptionalNullable[str] = UNSET
60
+
61
+ role: Optional[MessageOutputEntryRole] = "assistant"
62
+
63
+ @model_serializer(mode="wrap")
64
+ def serialize_model(self, handler):
65
+ optional_fields = [
66
+ "object",
67
+ "type",
68
+ "created_at",
69
+ "completed_at",
70
+ "id",
71
+ "agent_id",
72
+ "model",
73
+ "role",
74
+ ]
75
+ nullable_fields = ["completed_at", "agent_id", "model"]
76
+ null_default_fields = []
77
+
78
+ serialized = handler(self)
79
+
80
+ m = {}
81
+
82
+ for n, f in self.model_fields.items():
83
+ k = f.alias or n
84
+ val = serialized.get(k)
85
+ serialized.pop(k, None)
86
+
87
+ optional_nullable = k in optional_fields and k in nullable_fields
88
+ is_set = (
89
+ self.__pydantic_fields_set__.intersection({n})
90
+ or k in null_default_fields
91
+ ) # pylint: disable=no-member
92
+
93
+ if val is not None and val != UNSET_SENTINEL:
94
+ m[k] = val
95
+ elif val != UNSET_SENTINEL and (
96
+ not k in optional_fields or (optional_nullable and is_set)
97
+ ):
98
+ m[k] = val
99
+
100
+ return m
@@ -0,0 +1,93 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .outputcontentchunks import OutputContentChunks, OutputContentChunksTypedDict
5
+ from datetime import datetime
6
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
7
+ from pydantic import model_serializer
8
+ from typing import Literal, Optional, Union
9
+ from typing_extensions import NotRequired, TypeAliasType, TypedDict
10
+
11
+
12
+ MessageOutputEventType = Literal["message.output.delta"]
13
+
14
+ MessageOutputEventRole = Literal["assistant"]
15
+
16
+ MessageOutputEventContentTypedDict = TypeAliasType(
17
+ "MessageOutputEventContentTypedDict", Union[str, OutputContentChunksTypedDict]
18
+ )
19
+
20
+
21
+ MessageOutputEventContent = TypeAliasType(
22
+ "MessageOutputEventContent", Union[str, OutputContentChunks]
23
+ )
24
+
25
+
26
+ class MessageOutputEventTypedDict(TypedDict):
27
+ id: str
28
+ content: MessageOutputEventContentTypedDict
29
+ type: NotRequired[MessageOutputEventType]
30
+ created_at: NotRequired[datetime]
31
+ output_index: NotRequired[int]
32
+ content_index: NotRequired[int]
33
+ model: NotRequired[Nullable[str]]
34
+ agent_id: NotRequired[Nullable[str]]
35
+ role: NotRequired[MessageOutputEventRole]
36
+
37
+
38
+ class MessageOutputEvent(BaseModel):
39
+ id: str
40
+
41
+ content: MessageOutputEventContent
42
+
43
+ type: Optional[MessageOutputEventType] = "message.output.delta"
44
+
45
+ created_at: Optional[datetime] = None
46
+
47
+ output_index: Optional[int] = 0
48
+
49
+ content_index: Optional[int] = 0
50
+
51
+ model: OptionalNullable[str] = UNSET
52
+
53
+ agent_id: OptionalNullable[str] = UNSET
54
+
55
+ role: Optional[MessageOutputEventRole] = "assistant"
56
+
57
+ @model_serializer(mode="wrap")
58
+ def serialize_model(self, handler):
59
+ optional_fields = [
60
+ "type",
61
+ "created_at",
62
+ "output_index",
63
+ "content_index",
64
+ "model",
65
+ "agent_id",
66
+ "role",
67
+ ]
68
+ nullable_fields = ["model", "agent_id"]
69
+ null_default_fields = []
70
+
71
+ serialized = handler(self)
72
+
73
+ m = {}
74
+
75
+ for n, f in self.model_fields.items():
76
+ k = f.alias or n
77
+ val = serialized.get(k)
78
+ serialized.pop(k, None)
79
+
80
+ optional_nullable = k in optional_fields and k in nullable_fields
81
+ is_set = (
82
+ self.__pydantic_fields_set__.intersection({n})
83
+ or k in null_default_fields
84
+ ) # pylint: disable=no-member
85
+
86
+ if val is not None and val != UNSET_SENTINEL:
87
+ m[k] = val
88
+ elif val != UNSET_SENTINEL and (
89
+ not k in optional_fields or (optional_nullable and is_set)
90
+ ):
91
+ m[k] = val
92
+
93
+ return m
@@ -0,0 +1,127 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .codeinterpretertool import CodeInterpreterTool, CodeInterpreterToolTypedDict
5
+ from .completionargs import CompletionArgs, CompletionArgsTypedDict
6
+ from .documentlibrarytool import DocumentLibraryTool, DocumentLibraryToolTypedDict
7
+ from .functiontool import FunctionTool, FunctionToolTypedDict
8
+ from .imagegenerationtool import ImageGenerationTool, ImageGenerationToolTypedDict
9
+ from .websearchpremiumtool import WebSearchPremiumTool, WebSearchPremiumToolTypedDict
10
+ from .websearchtool import WebSearchTool, WebSearchToolTypedDict
11
+ from datetime import datetime
12
+ from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
13
+ from mistralai.utils import get_discriminator
14
+ from pydantic import Discriminator, Tag, model_serializer
15
+ from typing import List, Literal, Optional, Union
16
+ from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
17
+
18
+
19
+ ModelConversationToolsTypedDict = TypeAliasType(
20
+ "ModelConversationToolsTypedDict",
21
+ Union[
22
+ WebSearchToolTypedDict,
23
+ WebSearchPremiumToolTypedDict,
24
+ CodeInterpreterToolTypedDict,
25
+ ImageGenerationToolTypedDict,
26
+ FunctionToolTypedDict,
27
+ DocumentLibraryToolTypedDict,
28
+ ],
29
+ )
30
+
31
+
32
+ ModelConversationTools = Annotated[
33
+ Union[
34
+ Annotated[CodeInterpreterTool, Tag("code_interpreter")],
35
+ Annotated[DocumentLibraryTool, Tag("document_library")],
36
+ Annotated[FunctionTool, Tag("function")],
37
+ Annotated[ImageGenerationTool, Tag("image_generation")],
38
+ Annotated[WebSearchTool, Tag("web_search")],
39
+ Annotated[WebSearchPremiumTool, Tag("web_search_premium")],
40
+ ],
41
+ Discriminator(lambda m: get_discriminator(m, "type", "type")),
42
+ ]
43
+
44
+
45
+ ModelConversationObject = Literal["conversation"]
46
+
47
+
48
+ class ModelConversationTypedDict(TypedDict):
49
+ id: str
50
+ created_at: datetime
51
+ updated_at: datetime
52
+ model: str
53
+ instructions: NotRequired[Nullable[str]]
54
+ r"""Instruction prompt the model will follow during the conversation."""
55
+ tools: NotRequired[List[ModelConversationToolsTypedDict]]
56
+ r"""List of tools which are available to the model during the conversation."""
57
+ completion_args: NotRequired[CompletionArgsTypedDict]
58
+ r"""White-listed arguments from the completion API"""
59
+ name: NotRequired[Nullable[str]]
60
+ r"""Name given to the conversation."""
61
+ description: NotRequired[Nullable[str]]
62
+ r"""Description of the what the conversation is about."""
63
+ object: NotRequired[ModelConversationObject]
64
+
65
+
66
+ class ModelConversation(BaseModel):
67
+ id: str
68
+
69
+ created_at: datetime
70
+
71
+ updated_at: datetime
72
+
73
+ model: str
74
+
75
+ instructions: OptionalNullable[str] = UNSET
76
+ r"""Instruction prompt the model will follow during the conversation."""
77
+
78
+ tools: Optional[List[ModelConversationTools]] = None
79
+ r"""List of tools which are available to the model during the conversation."""
80
+
81
+ completion_args: Optional[CompletionArgs] = None
82
+ r"""White-listed arguments from the completion API"""
83
+
84
+ name: OptionalNullable[str] = UNSET
85
+ r"""Name given to the conversation."""
86
+
87
+ description: OptionalNullable[str] = UNSET
88
+ r"""Description of the what the conversation is about."""
89
+
90
+ object: Optional[ModelConversationObject] = "conversation"
91
+
92
+ @model_serializer(mode="wrap")
93
+ def serialize_model(self, handler):
94
+ optional_fields = [
95
+ "instructions",
96
+ "tools",
97
+ "completion_args",
98
+ "name",
99
+ "description",
100
+ "object",
101
+ ]
102
+ nullable_fields = ["instructions", "name", "description"]
103
+ null_default_fields = []
104
+
105
+ serialized = handler(self)
106
+
107
+ m = {}
108
+
109
+ for n, f in self.model_fields.items():
110
+ k = f.alias or n
111
+ val = serialized.get(k)
112
+ serialized.pop(k, None)
113
+
114
+ optional_nullable = k in optional_fields and k in nullable_fields
115
+ is_set = (
116
+ self.__pydantic_fields_set__.intersection({n})
117
+ or k in null_default_fields
118
+ ) # pylint: disable=no-member
119
+
120
+ if val is not None and val != UNSET_SENTINEL:
121
+ m[k] = val
122
+ elif val != UNSET_SENTINEL and (
123
+ not k in optional_fields or (optional_nullable and is_set)
124
+ ):
125
+ m[k] = val
126
+
127
+ return m
@@ -0,0 +1,30 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .documenturlchunk import DocumentURLChunk, DocumentURLChunkTypedDict
5
+ from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
6
+ from .textchunk import TextChunk, TextChunkTypedDict
7
+ from .toolfilechunk import ToolFileChunk, ToolFileChunkTypedDict
8
+ from .toolreferencechunk import ToolReferenceChunk, ToolReferenceChunkTypedDict
9
+ from typing import Union
10
+ from typing_extensions import TypeAliasType
11
+
12
+
13
+ OutputContentChunksTypedDict = TypeAliasType(
14
+ "OutputContentChunksTypedDict",
15
+ Union[
16
+ TextChunkTypedDict,
17
+ ImageURLChunkTypedDict,
18
+ DocumentURLChunkTypedDict,
19
+ ToolFileChunkTypedDict,
20
+ ToolReferenceChunkTypedDict,
21
+ ],
22
+ )
23
+
24
+
25
+ OutputContentChunks = TypeAliasType(
26
+ "OutputContentChunks",
27
+ Union[
28
+ TextChunk, ImageURLChunk, DocumentURLChunk, ToolFileChunk, ToolReferenceChunk
29
+ ],
30
+ )