mistralai 1.7.0__py3-none-any.whl → 1.8.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.
- mistralai/_version.py +3 -3
- mistralai/beta.py +20 -0
- mistralai/conversations.py +2657 -0
- mistralai/extra/__init__.py +10 -2
- mistralai/extra/exceptions.py +14 -0
- mistralai/extra/mcp/__init__.py +0 -0
- mistralai/extra/mcp/auth.py +166 -0
- mistralai/extra/mcp/base.py +155 -0
- mistralai/extra/mcp/sse.py +165 -0
- mistralai/extra/mcp/stdio.py +22 -0
- mistralai/extra/run/__init__.py +0 -0
- mistralai/extra/run/context.py +295 -0
- mistralai/extra/run/result.py +212 -0
- mistralai/extra/run/tools.py +225 -0
- mistralai/extra/run/utils.py +36 -0
- mistralai/extra/tests/test_struct_chat.py +1 -1
- mistralai/extra/utils/_pydantic_helper.py +2 -1
- mistralai/mistral_agents.py +1158 -0
- mistralai/models/__init__.py +470 -1
- mistralai/models/agent.py +129 -0
- mistralai/models/agentconversation.py +71 -0
- mistralai/models/agentcreationrequest.py +109 -0
- mistralai/models/agenthandoffdoneevent.py +33 -0
- mistralai/models/agenthandoffentry.py +75 -0
- mistralai/models/agenthandoffstartedevent.py +33 -0
- mistralai/models/agents_api_v1_agents_getop.py +16 -0
- mistralai/models/agents_api_v1_agents_listop.py +24 -0
- mistralai/models/agents_api_v1_agents_update_versionop.py +21 -0
- mistralai/models/agents_api_v1_agents_updateop.py +23 -0
- mistralai/models/agents_api_v1_conversations_append_streamop.py +28 -0
- mistralai/models/agents_api_v1_conversations_appendop.py +28 -0
- mistralai/models/agents_api_v1_conversations_getop.py +33 -0
- mistralai/models/agents_api_v1_conversations_historyop.py +16 -0
- mistralai/models/agents_api_v1_conversations_listop.py +37 -0
- mistralai/models/agents_api_v1_conversations_messagesop.py +16 -0
- mistralai/models/agents_api_v1_conversations_restart_streamop.py +26 -0
- mistralai/models/agents_api_v1_conversations_restartop.py +26 -0
- mistralai/models/agentupdaterequest.py +111 -0
- mistralai/models/builtinconnectors.py +13 -0
- mistralai/models/codeinterpretertool.py +17 -0
- mistralai/models/completionargs.py +100 -0
- mistralai/models/completionargsstop.py +13 -0
- mistralai/models/completionjobout.py +3 -3
- mistralai/models/conversationappendrequest.py +35 -0
- mistralai/models/conversationappendstreamrequest.py +37 -0
- mistralai/models/conversationevents.py +72 -0
- mistralai/models/conversationhistory.py +58 -0
- mistralai/models/conversationinputs.py +14 -0
- mistralai/models/conversationmessages.py +28 -0
- mistralai/models/conversationrequest.py +133 -0
- mistralai/models/conversationresponse.py +51 -0
- mistralai/models/conversationrestartrequest.py +42 -0
- mistralai/models/conversationrestartstreamrequest.py +44 -0
- mistralai/models/conversationstreamrequest.py +135 -0
- mistralai/models/conversationusageinfo.py +63 -0
- mistralai/models/documentlibrarytool.py +22 -0
- mistralai/models/functioncallentry.py +76 -0
- mistralai/models/functioncallentryarguments.py +15 -0
- mistralai/models/functioncallevent.py +36 -0
- mistralai/models/functionresultentry.py +69 -0
- mistralai/models/functiontool.py +21 -0
- mistralai/models/imagegenerationtool.py +17 -0
- mistralai/models/inputentries.py +18 -0
- mistralai/models/messageentries.py +18 -0
- mistralai/models/messageinputcontentchunks.py +26 -0
- mistralai/models/messageinputentry.py +89 -0
- mistralai/models/messageoutputcontentchunks.py +30 -0
- mistralai/models/messageoutputentry.py +100 -0
- mistralai/models/messageoutputevent.py +93 -0
- mistralai/models/modelconversation.py +127 -0
- mistralai/models/ocrimageobject.py +7 -1
- mistralai/models/ocrrequest.py +15 -0
- mistralai/models/ocrresponse.py +38 -2
- mistralai/models/outputcontentchunks.py +30 -0
- mistralai/models/responsedoneevent.py +25 -0
- mistralai/models/responseerrorevent.py +27 -0
- mistralai/models/responsestartedevent.py +24 -0
- mistralai/models/ssetypes.py +18 -0
- mistralai/models/toolexecutiondoneevent.py +34 -0
- mistralai/models/toolexecutionentry.py +70 -0
- mistralai/models/toolexecutionstartedevent.py +31 -0
- mistralai/models/toolfilechunk.py +61 -0
- mistralai/models/toolreferencechunk.py +61 -0
- mistralai/models/websearchpremiumtool.py +17 -0
- mistralai/models/websearchtool.py +17 -0
- mistralai/ocr.py +28 -0
- mistralai/sdk.py +3 -0
- {mistralai-1.7.0.dist-info → mistralai-1.8.0.dist-info}/METADATA +42 -7
- {mistralai-1.7.0.dist-info → mistralai-1.8.0.dist-info}/RECORD +91 -15
- {mistralai-1.7.0.dist-info → mistralai-1.8.0.dist-info}/WHEEL +1 -1
- {mistralai-1.7.0.dist-info → mistralai-1.8.0.dist-info}/LICENSE +0 -0
|
@@ -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
|
|
@@ -19,6 +19,8 @@ class OCRImageObjectTypedDict(TypedDict):
|
|
|
19
19
|
r"""Y coordinate of bottom-right corner of the extracted image"""
|
|
20
20
|
image_base64: NotRequired[Nullable[str]]
|
|
21
21
|
r"""Base64 string of the extracted image"""
|
|
22
|
+
image_annotation: NotRequired[Nullable[str]]
|
|
23
|
+
r"""Annotation of the extracted image in json str"""
|
|
22
24
|
|
|
23
25
|
|
|
24
26
|
class OCRImageObject(BaseModel):
|
|
@@ -40,15 +42,19 @@ class OCRImageObject(BaseModel):
|
|
|
40
42
|
image_base64: OptionalNullable[str] = UNSET
|
|
41
43
|
r"""Base64 string of the extracted image"""
|
|
42
44
|
|
|
45
|
+
image_annotation: OptionalNullable[str] = UNSET
|
|
46
|
+
r"""Annotation of the extracted image in json str"""
|
|
47
|
+
|
|
43
48
|
@model_serializer(mode="wrap")
|
|
44
49
|
def serialize_model(self, handler):
|
|
45
|
-
optional_fields = ["image_base64"]
|
|
50
|
+
optional_fields = ["image_base64", "image_annotation"]
|
|
46
51
|
nullable_fields = [
|
|
47
52
|
"top_left_x",
|
|
48
53
|
"top_left_y",
|
|
49
54
|
"bottom_right_x",
|
|
50
55
|
"bottom_right_y",
|
|
51
56
|
"image_base64",
|
|
57
|
+
"image_annotation",
|
|
52
58
|
]
|
|
53
59
|
null_default_fields = []
|
|
54
60
|
|
mistralai/models/ocrrequest.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .documenturlchunk import DocumentURLChunk, DocumentURLChunkTypedDict
|
|
5
5
|
from .imageurlchunk import ImageURLChunk, ImageURLChunkTypedDict
|
|
6
|
+
from .responseformat import ResponseFormat, ResponseFormatTypedDict
|
|
6
7
|
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
7
8
|
from pydantic import model_serializer
|
|
8
9
|
from typing import List, Optional, Union
|
|
@@ -32,6 +33,10 @@ class OCRRequestTypedDict(TypedDict):
|
|
|
32
33
|
r"""Max images to extract"""
|
|
33
34
|
image_min_size: NotRequired[Nullable[int]]
|
|
34
35
|
r"""Minimum height and width of image to extract"""
|
|
36
|
+
bbox_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
|
|
37
|
+
r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
|
|
38
|
+
document_annotation_format: NotRequired[Nullable[ResponseFormatTypedDict]]
|
|
39
|
+
r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
|
|
35
40
|
|
|
36
41
|
|
|
37
42
|
class OCRRequest(BaseModel):
|
|
@@ -54,6 +59,12 @@ class OCRRequest(BaseModel):
|
|
|
54
59
|
image_min_size: OptionalNullable[int] = UNSET
|
|
55
60
|
r"""Minimum height and width of image to extract"""
|
|
56
61
|
|
|
62
|
+
bbox_annotation_format: OptionalNullable[ResponseFormat] = UNSET
|
|
63
|
+
r"""Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field"""
|
|
64
|
+
|
|
65
|
+
document_annotation_format: OptionalNullable[ResponseFormat] = UNSET
|
|
66
|
+
r"""Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field"""
|
|
67
|
+
|
|
57
68
|
@model_serializer(mode="wrap")
|
|
58
69
|
def serialize_model(self, handler):
|
|
59
70
|
optional_fields = [
|
|
@@ -62,6 +73,8 @@ class OCRRequest(BaseModel):
|
|
|
62
73
|
"include_image_base64",
|
|
63
74
|
"image_limit",
|
|
64
75
|
"image_min_size",
|
|
76
|
+
"bbox_annotation_format",
|
|
77
|
+
"document_annotation_format",
|
|
65
78
|
]
|
|
66
79
|
nullable_fields = [
|
|
67
80
|
"model",
|
|
@@ -69,6 +82,8 @@ class OCRRequest(BaseModel):
|
|
|
69
82
|
"include_image_base64",
|
|
70
83
|
"image_limit",
|
|
71
84
|
"image_min_size",
|
|
85
|
+
"bbox_annotation_format",
|
|
86
|
+
"document_annotation_format",
|
|
72
87
|
]
|
|
73
88
|
null_default_fields = []
|
|
74
89
|
|
mistralai/models/ocrresponse.py
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from .ocrpageobject import OCRPageObject, OCRPageObjectTypedDict
|
|
5
5
|
from .ocrusageinfo import OCRUsageInfo, OCRUsageInfoTypedDict
|
|
6
|
-
from mistralai.types import BaseModel
|
|
6
|
+
from mistralai.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
|
|
7
|
+
from pydantic import model_serializer
|
|
7
8
|
from typing import List
|
|
8
|
-
from typing_extensions import TypedDict
|
|
9
|
+
from typing_extensions import NotRequired, TypedDict
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class OCRResponseTypedDict(TypedDict):
|
|
@@ -14,6 +15,8 @@ class OCRResponseTypedDict(TypedDict):
|
|
|
14
15
|
model: str
|
|
15
16
|
r"""The model used to generate the OCR."""
|
|
16
17
|
usage_info: OCRUsageInfoTypedDict
|
|
18
|
+
document_annotation: NotRequired[Nullable[str]]
|
|
19
|
+
r"""Formatted response in the request_format if provided in json str"""
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
class OCRResponse(BaseModel):
|
|
@@ -24,3 +27,36 @@ class OCRResponse(BaseModel):
|
|
|
24
27
|
r"""The model used to generate the OCR."""
|
|
25
28
|
|
|
26
29
|
usage_info: OCRUsageInfo
|
|
30
|
+
|
|
31
|
+
document_annotation: OptionalNullable[str] = UNSET
|
|
32
|
+
r"""Formatted response in the request_format if provided in json str"""
|
|
33
|
+
|
|
34
|
+
@model_serializer(mode="wrap")
|
|
35
|
+
def serialize_model(self, handler):
|
|
36
|
+
optional_fields = ["document_annotation"]
|
|
37
|
+
nullable_fields = ["document_annotation"]
|
|
38
|
+
null_default_fields = []
|
|
39
|
+
|
|
40
|
+
serialized = handler(self)
|
|
41
|
+
|
|
42
|
+
m = {}
|
|
43
|
+
|
|
44
|
+
for n, f in self.model_fields.items():
|
|
45
|
+
k = f.alias or n
|
|
46
|
+
val = serialized.get(k)
|
|
47
|
+
serialized.pop(k, None)
|
|
48
|
+
|
|
49
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
50
|
+
is_set = (
|
|
51
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
52
|
+
or k in null_default_fields
|
|
53
|
+
) # pylint: disable=no-member
|
|
54
|
+
|
|
55
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
56
|
+
m[k] = val
|
|
57
|
+
elif val != UNSET_SENTINEL and (
|
|
58
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
59
|
+
):
|
|
60
|
+
m[k] = val
|
|
61
|
+
|
|
62
|
+
return m
|