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,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
|
+
)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .conversationusageinfo import ConversationUsageInfo, ConversationUsageInfoTypedDict
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from mistralai.types import BaseModel
|
|
7
|
+
from typing import Literal, Optional
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
ResponseDoneEventType = Literal["conversation.response.done"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ResponseDoneEventTypedDict(TypedDict):
|
|
15
|
+
usage: ConversationUsageInfoTypedDict
|
|
16
|
+
type: NotRequired[ResponseDoneEventType]
|
|
17
|
+
created_at: NotRequired[datetime]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ResponseDoneEvent(BaseModel):
|
|
21
|
+
usage: ConversationUsageInfo
|
|
22
|
+
|
|
23
|
+
type: Optional[ResponseDoneEventType] = "conversation.response.done"
|
|
24
|
+
|
|
25
|
+
created_at: Optional[datetime] = None
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
ResponseErrorEventType = Literal["conversation.response.error"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ResponseErrorEventTypedDict(TypedDict):
|
|
14
|
+
message: str
|
|
15
|
+
code: int
|
|
16
|
+
type: NotRequired[ResponseErrorEventType]
|
|
17
|
+
created_at: NotRequired[datetime]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ResponseErrorEvent(BaseModel):
|
|
21
|
+
message: str
|
|
22
|
+
|
|
23
|
+
code: int
|
|
24
|
+
|
|
25
|
+
type: Optional[ResponseErrorEventType] = "conversation.response.error"
|
|
26
|
+
|
|
27
|
+
created_at: Optional[datetime] = None
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
ResponseStartedEventType = Literal["conversation.response.started"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ResponseStartedEventTypedDict(TypedDict):
|
|
14
|
+
conversation_id: str
|
|
15
|
+
type: NotRequired[ResponseStartedEventType]
|
|
16
|
+
created_at: NotRequired[datetime]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ResponseStartedEvent(BaseModel):
|
|
20
|
+
conversation_id: str
|
|
21
|
+
|
|
22
|
+
type: Optional[ResponseStartedEventType] = "conversation.response.started"
|
|
23
|
+
|
|
24
|
+
created_at: Optional[datetime] = None
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from typing import Literal
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
SSETypes = Literal[
|
|
8
|
+
"conversation.response.started",
|
|
9
|
+
"conversation.response.done",
|
|
10
|
+
"conversation.response.error",
|
|
11
|
+
"message.output.delta",
|
|
12
|
+
"tool.execution.started",
|
|
13
|
+
"tool.execution.done",
|
|
14
|
+
"agent.handoff.started",
|
|
15
|
+
"agent.handoff.done",
|
|
16
|
+
"function.call.delta",
|
|
17
|
+
]
|
|
18
|
+
r"""Server side events sent when streaming a conversation response."""
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .builtinconnectors import BuiltInConnectors
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from mistralai.types import BaseModel
|
|
7
|
+
from typing import Any, Dict, Literal, Optional
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
ToolExecutionDoneEventType = Literal["tool.execution.done"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ToolExecutionDoneEventTypedDict(TypedDict):
|
|
15
|
+
id: str
|
|
16
|
+
name: BuiltInConnectors
|
|
17
|
+
type: NotRequired[ToolExecutionDoneEventType]
|
|
18
|
+
created_at: NotRequired[datetime]
|
|
19
|
+
output_index: NotRequired[int]
|
|
20
|
+
info: NotRequired[Dict[str, Any]]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ToolExecutionDoneEvent(BaseModel):
|
|
24
|
+
id: str
|
|
25
|
+
|
|
26
|
+
name: BuiltInConnectors
|
|
27
|
+
|
|
28
|
+
type: Optional[ToolExecutionDoneEventType] = "tool.execution.done"
|
|
29
|
+
|
|
30
|
+
created_at: Optional[datetime] = None
|
|
31
|
+
|
|
32
|
+
output_index: Optional[int] = 0
|
|
33
|
+
|
|
34
|
+
info: Optional[Dict[str, Any]] = None
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .builtinconnectors import BuiltInConnectors
|
|
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 Any, Dict, Literal, Optional
|
|
9
|
+
from typing_extensions import NotRequired, TypedDict
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
ToolExecutionEntryObject = Literal["entry"]
|
|
13
|
+
|
|
14
|
+
ToolExecutionEntryType = Literal["tool.execution"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ToolExecutionEntryTypedDict(TypedDict):
|
|
18
|
+
name: BuiltInConnectors
|
|
19
|
+
object: NotRequired[ToolExecutionEntryObject]
|
|
20
|
+
type: NotRequired[ToolExecutionEntryType]
|
|
21
|
+
created_at: NotRequired[datetime]
|
|
22
|
+
completed_at: NotRequired[Nullable[datetime]]
|
|
23
|
+
id: NotRequired[str]
|
|
24
|
+
info: NotRequired[Dict[str, Any]]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ToolExecutionEntry(BaseModel):
|
|
28
|
+
name: BuiltInConnectors
|
|
29
|
+
|
|
30
|
+
object: Optional[ToolExecutionEntryObject] = "entry"
|
|
31
|
+
|
|
32
|
+
type: Optional[ToolExecutionEntryType] = "tool.execution"
|
|
33
|
+
|
|
34
|
+
created_at: Optional[datetime] = None
|
|
35
|
+
|
|
36
|
+
completed_at: OptionalNullable[datetime] = UNSET
|
|
37
|
+
|
|
38
|
+
id: Optional[str] = None
|
|
39
|
+
|
|
40
|
+
info: Optional[Dict[str, Any]] = None
|
|
41
|
+
|
|
42
|
+
@model_serializer(mode="wrap")
|
|
43
|
+
def serialize_model(self, handler):
|
|
44
|
+
optional_fields = ["object", "type", "created_at", "completed_at", "id", "info"]
|
|
45
|
+
nullable_fields = ["completed_at"]
|
|
46
|
+
null_default_fields = []
|
|
47
|
+
|
|
48
|
+
serialized = handler(self)
|
|
49
|
+
|
|
50
|
+
m = {}
|
|
51
|
+
|
|
52
|
+
for n, f in self.model_fields.items():
|
|
53
|
+
k = f.alias or n
|
|
54
|
+
val = serialized.get(k)
|
|
55
|
+
serialized.pop(k, None)
|
|
56
|
+
|
|
57
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
58
|
+
is_set = (
|
|
59
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
60
|
+
or k in null_default_fields
|
|
61
|
+
) # pylint: disable=no-member
|
|
62
|
+
|
|
63
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
64
|
+
m[k] = val
|
|
65
|
+
elif val != UNSET_SENTINEL and (
|
|
66
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
67
|
+
):
|
|
68
|
+
m[k] = val
|
|
69
|
+
|
|
70
|
+
return m
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .builtinconnectors import BuiltInConnectors
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from mistralai.types import BaseModel
|
|
7
|
+
from typing import Literal, Optional
|
|
8
|
+
from typing_extensions import NotRequired, TypedDict
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
ToolExecutionStartedEventType = Literal["tool.execution.started"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ToolExecutionStartedEventTypedDict(TypedDict):
|
|
15
|
+
id: str
|
|
16
|
+
name: BuiltInConnectors
|
|
17
|
+
type: NotRequired[ToolExecutionStartedEventType]
|
|
18
|
+
created_at: NotRequired[datetime]
|
|
19
|
+
output_index: NotRequired[int]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ToolExecutionStartedEvent(BaseModel):
|
|
23
|
+
id: str
|
|
24
|
+
|
|
25
|
+
name: BuiltInConnectors
|
|
26
|
+
|
|
27
|
+
type: Optional[ToolExecutionStartedEventType] = "tool.execution.started"
|
|
28
|
+
|
|
29
|
+
created_at: Optional[datetime] = None
|
|
30
|
+
|
|
31
|
+
output_index: Optional[int] = 0
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .builtinconnectors import BuiltInConnectors
|
|
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
|
+
ToolFileChunkType = Literal["tool_file"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ToolFileChunkTypedDict(TypedDict):
|
|
15
|
+
tool: BuiltInConnectors
|
|
16
|
+
file_id: str
|
|
17
|
+
type: NotRequired[ToolFileChunkType]
|
|
18
|
+
file_name: NotRequired[Nullable[str]]
|
|
19
|
+
file_type: NotRequired[Nullable[str]]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ToolFileChunk(BaseModel):
|
|
23
|
+
tool: BuiltInConnectors
|
|
24
|
+
|
|
25
|
+
file_id: str
|
|
26
|
+
|
|
27
|
+
type: Optional[ToolFileChunkType] = "tool_file"
|
|
28
|
+
|
|
29
|
+
file_name: OptionalNullable[str] = UNSET
|
|
30
|
+
|
|
31
|
+
file_type: OptionalNullable[str] = UNSET
|
|
32
|
+
|
|
33
|
+
@model_serializer(mode="wrap")
|
|
34
|
+
def serialize_model(self, handler):
|
|
35
|
+
optional_fields = ["type", "file_name", "file_type"]
|
|
36
|
+
nullable_fields = ["file_name", "file_type"]
|
|
37
|
+
null_default_fields = []
|
|
38
|
+
|
|
39
|
+
serialized = handler(self)
|
|
40
|
+
|
|
41
|
+
m = {}
|
|
42
|
+
|
|
43
|
+
for n, f in self.model_fields.items():
|
|
44
|
+
k = f.alias or n
|
|
45
|
+
val = serialized.get(k)
|
|
46
|
+
serialized.pop(k, None)
|
|
47
|
+
|
|
48
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
49
|
+
is_set = (
|
|
50
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
51
|
+
or k in null_default_fields
|
|
52
|
+
) # pylint: disable=no-member
|
|
53
|
+
|
|
54
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
55
|
+
m[k] = val
|
|
56
|
+
elif val != UNSET_SENTINEL and (
|
|
57
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
58
|
+
):
|
|
59
|
+
m[k] = val
|
|
60
|
+
|
|
61
|
+
return m
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from .builtinconnectors import BuiltInConnectors
|
|
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
|
+
ToolReferenceChunkType = Literal["tool_reference"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ToolReferenceChunkTypedDict(TypedDict):
|
|
15
|
+
tool: BuiltInConnectors
|
|
16
|
+
title: str
|
|
17
|
+
type: NotRequired[ToolReferenceChunkType]
|
|
18
|
+
url: NotRequired[Nullable[str]]
|
|
19
|
+
source: NotRequired[Nullable[str]]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ToolReferenceChunk(BaseModel):
|
|
23
|
+
tool: BuiltInConnectors
|
|
24
|
+
|
|
25
|
+
title: str
|
|
26
|
+
|
|
27
|
+
type: Optional[ToolReferenceChunkType] = "tool_reference"
|
|
28
|
+
|
|
29
|
+
url: OptionalNullable[str] = UNSET
|
|
30
|
+
|
|
31
|
+
source: OptionalNullable[str] = UNSET
|
|
32
|
+
|
|
33
|
+
@model_serializer(mode="wrap")
|
|
34
|
+
def serialize_model(self, handler):
|
|
35
|
+
optional_fields = ["type", "url", "source"]
|
|
36
|
+
nullable_fields = ["url", "source"]
|
|
37
|
+
null_default_fields = []
|
|
38
|
+
|
|
39
|
+
serialized = handler(self)
|
|
40
|
+
|
|
41
|
+
m = {}
|
|
42
|
+
|
|
43
|
+
for n, f in self.model_fields.items():
|
|
44
|
+
k = f.alias or n
|
|
45
|
+
val = serialized.get(k)
|
|
46
|
+
serialized.pop(k, None)
|
|
47
|
+
|
|
48
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
49
|
+
is_set = (
|
|
50
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
51
|
+
or k in null_default_fields
|
|
52
|
+
) # pylint: disable=no-member
|
|
53
|
+
|
|
54
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
55
|
+
m[k] = val
|
|
56
|
+
elif val != UNSET_SENTINEL and (
|
|
57
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
58
|
+
):
|
|
59
|
+
m[k] = val
|
|
60
|
+
|
|
61
|
+
return m
|
|
@@ -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
|
+
WebSearchPremiumToolType = Literal["web_search_premium"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class WebSearchPremiumToolTypedDict(TypedDict):
|
|
13
|
+
type: NotRequired[WebSearchPremiumToolType]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class WebSearchPremiumTool(BaseModel):
|
|
17
|
+
type: Optional[WebSearchPremiumToolType] = "web_search_premium"
|
|
@@ -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
|
+
WebSearchToolType = Literal["web_search"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class WebSearchToolTypedDict(TypedDict):
|
|
13
|
+
type: NotRequired[WebSearchToolType]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class WebSearchTool(BaseModel):
|
|
17
|
+
type: Optional[WebSearchToolType] = "web_search"
|
mistralai/ocr.py
CHANGED
|
@@ -21,6 +21,12 @@ class Ocr(BaseSDK):
|
|
|
21
21
|
include_image_base64: OptionalNullable[bool] = UNSET,
|
|
22
22
|
image_limit: OptionalNullable[int] = UNSET,
|
|
23
23
|
image_min_size: OptionalNullable[int] = UNSET,
|
|
24
|
+
bbox_annotation_format: OptionalNullable[
|
|
25
|
+
Union[models.ResponseFormat, models.ResponseFormatTypedDict]
|
|
26
|
+
] = UNSET,
|
|
27
|
+
document_annotation_format: OptionalNullable[
|
|
28
|
+
Union[models.ResponseFormat, models.ResponseFormatTypedDict]
|
|
29
|
+
] = UNSET,
|
|
24
30
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
25
31
|
server_url: Optional[str] = None,
|
|
26
32
|
timeout_ms: Optional[int] = None,
|
|
@@ -35,6 +41,8 @@ class Ocr(BaseSDK):
|
|
|
35
41
|
:param include_image_base64: Include image URLs in response
|
|
36
42
|
:param image_limit: Max images to extract
|
|
37
43
|
:param image_min_size: Minimum height and width of image to extract
|
|
44
|
+
:param bbox_annotation_format: Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field
|
|
45
|
+
:param document_annotation_format: Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field
|
|
38
46
|
:param retries: Override the default retry configuration for this method
|
|
39
47
|
:param server_url: Override the default server URL for this method
|
|
40
48
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -58,6 +66,12 @@ class Ocr(BaseSDK):
|
|
|
58
66
|
include_image_base64=include_image_base64,
|
|
59
67
|
image_limit=image_limit,
|
|
60
68
|
image_min_size=image_min_size,
|
|
69
|
+
bbox_annotation_format=utils.get_pydantic_model(
|
|
70
|
+
bbox_annotation_format, OptionalNullable[models.ResponseFormat]
|
|
71
|
+
),
|
|
72
|
+
document_annotation_format=utils.get_pydantic_model(
|
|
73
|
+
document_annotation_format, OptionalNullable[models.ResponseFormat]
|
|
74
|
+
),
|
|
61
75
|
)
|
|
62
76
|
|
|
63
77
|
req = self._build_request(
|
|
@@ -139,6 +153,12 @@ class Ocr(BaseSDK):
|
|
|
139
153
|
include_image_base64: OptionalNullable[bool] = UNSET,
|
|
140
154
|
image_limit: OptionalNullable[int] = UNSET,
|
|
141
155
|
image_min_size: OptionalNullable[int] = UNSET,
|
|
156
|
+
bbox_annotation_format: OptionalNullable[
|
|
157
|
+
Union[models.ResponseFormat, models.ResponseFormatTypedDict]
|
|
158
|
+
] = UNSET,
|
|
159
|
+
document_annotation_format: OptionalNullable[
|
|
160
|
+
Union[models.ResponseFormat, models.ResponseFormatTypedDict]
|
|
161
|
+
] = UNSET,
|
|
142
162
|
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
143
163
|
server_url: Optional[str] = None,
|
|
144
164
|
timeout_ms: Optional[int] = None,
|
|
@@ -153,6 +173,8 @@ class Ocr(BaseSDK):
|
|
|
153
173
|
:param include_image_base64: Include image URLs in response
|
|
154
174
|
:param image_limit: Max images to extract
|
|
155
175
|
:param image_min_size: Minimum height and width of image to extract
|
|
176
|
+
:param bbox_annotation_format: Structured output class for extracting useful information from each extracted bounding box / image from document. Only json_schema is valid for this field
|
|
177
|
+
:param document_annotation_format: Structured output class for extracting useful information from the entire document. Only json_schema is valid for this field
|
|
156
178
|
:param retries: Override the default retry configuration for this method
|
|
157
179
|
:param server_url: Override the default server URL for this method
|
|
158
180
|
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
@@ -176,6 +198,12 @@ class Ocr(BaseSDK):
|
|
|
176
198
|
include_image_base64=include_image_base64,
|
|
177
199
|
image_limit=image_limit,
|
|
178
200
|
image_min_size=image_min_size,
|
|
201
|
+
bbox_annotation_format=utils.get_pydantic_model(
|
|
202
|
+
bbox_annotation_format, OptionalNullable[models.ResponseFormat]
|
|
203
|
+
),
|
|
204
|
+
document_annotation_format=utils.get_pydantic_model(
|
|
205
|
+
document_annotation_format, OptionalNullable[models.ResponseFormat]
|
|
206
|
+
),
|
|
179
207
|
)
|
|
180
208
|
|
|
181
209
|
req = self._build_request_async(
|
mistralai/sdk.py
CHANGED
|
@@ -10,6 +10,7 @@ from mistralai import models, utils
|
|
|
10
10
|
from mistralai._hooks import SDKHooks
|
|
11
11
|
from mistralai.agents import Agents
|
|
12
12
|
from mistralai.batch import Batch
|
|
13
|
+
from mistralai.beta import Beta
|
|
13
14
|
from mistralai.chat import Chat
|
|
14
15
|
from mistralai.classifiers import Classifiers
|
|
15
16
|
from mistralai.embeddings import Embeddings
|
|
@@ -28,6 +29,7 @@ class Mistral(BaseSDK):
|
|
|
28
29
|
|
|
29
30
|
models: Models
|
|
30
31
|
r"""Model Management API"""
|
|
32
|
+
beta: Beta
|
|
31
33
|
files: Files
|
|
32
34
|
r"""Files API"""
|
|
33
35
|
fine_tuning: FineTuning
|
|
@@ -142,6 +144,7 @@ class Mistral(BaseSDK):
|
|
|
142
144
|
|
|
143
145
|
def _init_sdks(self):
|
|
144
146
|
self.models = Models(self.sdk_configuration)
|
|
147
|
+
self.beta = Beta(self.sdk_configuration)
|
|
145
148
|
self.files = Files(self.sdk_configuration)
|
|
146
149
|
self.fine_tuning = FineTuning(self.sdk_configuration)
|
|
147
150
|
self.batch = Batch(self.sdk_configuration)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mistralai
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
4
4
|
Summary: Python Client SDK for the Mistral AI API.
|
|
5
5
|
Author: Mistral
|
|
6
6
|
Requires-Python: >=3.9
|
|
@@ -10,10 +10,14 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Provides-Extra: agents
|
|
13
14
|
Provides-Extra: gcp
|
|
15
|
+
Requires-Dist: authlib (>=1.5.2,<2.0) ; extra == "agents"
|
|
14
16
|
Requires-Dist: eval-type-backport (>=0.2.0)
|
|
15
17
|
Requires-Dist: google-auth (>=2.27.0) ; extra == "gcp"
|
|
18
|
+
Requires-Dist: griffe (>=1.7.3,<2.0) ; extra == "agents"
|
|
16
19
|
Requires-Dist: httpx (>=0.28.1)
|
|
20
|
+
Requires-Dist: mcp (>=1.0,<2.0) ; (python_version >= "3.10") and (extra == "agents")
|
|
17
21
|
Requires-Dist: pydantic (>=2.10.3)
|
|
18
22
|
Requires-Dist: python-dateutil (>=2.8.2)
|
|
19
23
|
Requires-Dist: requests (>=2.32.3) ; extra == "gcp"
|
|
@@ -131,6 +135,18 @@ Once that is saved to a file, you can run it with `uv run script.py` where
|
|
|
131
135
|
`script.py` can be replaced with the actual file name.
|
|
132
136
|
<!-- End SDK Installation [installation] -->
|
|
133
137
|
|
|
138
|
+
### Agents extra dependencies
|
|
139
|
+
|
|
140
|
+
When using the agents related feature it is required to add the `agents` extra dependencies. This can be added when
|
|
141
|
+
installing the package:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install "mistralai[agents]"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> Note: Because of some of our dependencies, these features are only available for python version higher or equal to
|
|
148
|
+
> 3.10.
|
|
149
|
+
|
|
134
150
|
<!-- Start SDK Example Usage [usage] -->
|
|
135
151
|
## SDK Example Usage
|
|
136
152
|
|
|
@@ -455,6 +471,30 @@ The documentation for the GCP SDK is available [here](https://github.com/mistral
|
|
|
455
471
|
* [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#get) - Get Batch Job
|
|
456
472
|
* [cancel](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistraljobs/README.md#cancel) - Cancel Batch Job
|
|
457
473
|
|
|
474
|
+
### [beta](https://github.com/mistralai/client-python/blob/master/docs/sdks/beta/README.md)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
#### [beta.agents](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistralagents/README.md)
|
|
478
|
+
|
|
479
|
+
* [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistralagents/README.md#create) - Create a agent that can be used within a conversation.
|
|
480
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistralagents/README.md#list) - List agent entities.
|
|
481
|
+
* [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistralagents/README.md#get) - Retrieve an agent entity.
|
|
482
|
+
* [update](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistralagents/README.md#update) - Update an agent entity.
|
|
483
|
+
* [update_version](https://github.com/mistralai/client-python/blob/master/docs/sdks/mistralagents/README.md#update_version) - Update an agent version.
|
|
484
|
+
|
|
485
|
+
#### [beta.conversations](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md)
|
|
486
|
+
|
|
487
|
+
* [start](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#start) - Create a conversation and append entries to it.
|
|
488
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#list) - List all created conversations.
|
|
489
|
+
* [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#get) - Retrieve a conversation information.
|
|
490
|
+
* [append](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#append) - Append new entries to an existing conversation.
|
|
491
|
+
* [get_history](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#get_history) - Retrieve all entries in a conversation.
|
|
492
|
+
* [get_messages](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#get_messages) - Retrieve all messages in a conversation.
|
|
493
|
+
* [restart](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#restart) - Restart a conversation starting from a given entry.
|
|
494
|
+
* [start_stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#start_stream) - Create a conversation and append entries to it.
|
|
495
|
+
* [append_stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#append_stream) - Append new entries to an existing conversation.
|
|
496
|
+
* [restart_stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/conversations/README.md#restart_stream) - Restart a conversation starting from a given entry.
|
|
497
|
+
|
|
458
498
|
### [chat](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md)
|
|
459
499
|
|
|
460
500
|
* [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md#complete) - Chat Completion
|
|
@@ -534,12 +574,7 @@ with Mistral(
|
|
|
534
574
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
535
575
|
) as mistral:
|
|
536
576
|
|
|
537
|
-
res = mistral.
|
|
538
|
-
{
|
|
539
|
-
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
540
|
-
"role": "user",
|
|
541
|
-
},
|
|
542
|
-
])
|
|
577
|
+
res = mistral.beta.conversations.start_stream(inputs="<value>")
|
|
543
578
|
|
|
544
579
|
with res as event_stream:
|
|
545
580
|
for event in event_stream:
|