mistralai 1.8.2__py3-none-any.whl → 1.9.2__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/_hooks/types.py +7 -0
- mistralai/_version.py +3 -3
- mistralai/accesses.py +672 -0
- mistralai/agents.py +8 -4
- mistralai/basesdk.py +12 -20
- mistralai/beta.py +4 -0
- mistralai/chat.py +8 -4
- mistralai/classifiers.py +8 -0
- mistralai/conversations.py +34 -14
- mistralai/documents.py +2136 -0
- mistralai/embeddings.py +2 -0
- mistralai/extra/run/context.py +2 -4
- mistralai/files.py +14 -2
- mistralai/fim.py +4 -0
- mistralai/httpclient.py +6 -16
- mistralai/jobs.py +10 -0
- mistralai/libraries.py +1041 -0
- mistralai/mistral_agents.py +10 -0
- mistralai/mistral_jobs.py +8 -0
- mistralai/models/__init__.py +1578 -721
- mistralai/models/agent.py +1 -1
- mistralai/models/agentconversation.py +1 -1
- mistralai/models/agentcreationrequest.py +1 -1
- mistralai/models/agenthandoffentry.py +1 -1
- mistralai/models/agents_api_v1_conversations_getop.py +2 -0
- mistralai/models/agents_api_v1_conversations_historyop.py +2 -0
- mistralai/models/agents_api_v1_conversations_messagesop.py +2 -0
- mistralai/models/agents_api_v1_conversations_restart_streamop.py +2 -0
- mistralai/models/agents_api_v1_conversations_restartop.py +2 -0
- mistralai/models/agentscompletionrequest.py +3 -1
- mistralai/models/agentscompletionstreamrequest.py +3 -1
- mistralai/models/agentupdaterequest.py +1 -1
- mistralai/models/assistantmessage.py +1 -1
- mistralai/models/basemodelcard.py +6 -1
- mistralai/models/batchjobin.py +1 -1
- mistralai/models/batchjobout.py +1 -1
- mistralai/models/chatcompletionrequest.py +3 -1
- mistralai/models/chatcompletionstreamrequest.py +3 -1
- mistralai/models/classifierdetailedjobout.py +1 -1
- mistralai/models/classifierftmodelout.py +1 -1
- mistralai/models/classifierjobout.py +1 -1
- mistralai/models/classifiertargetin.py +1 -1
- mistralai/models/classifiertrainingparameters.py +1 -1
- mistralai/models/classifiertrainingparametersin.py +1 -1
- mistralai/models/completionargs.py +1 -1
- mistralai/models/completiondetailedjobout.py +1 -1
- mistralai/models/completionftmodelout.py +1 -1
- mistralai/models/completionjobout.py +1 -1
- mistralai/models/completionresponsestreamchoice.py +1 -1
- mistralai/models/completiontrainingparameters.py +1 -1
- mistralai/models/completiontrainingparametersin.py +1 -1
- mistralai/models/contentchunk.py +3 -0
- mistralai/models/conversationevents.py +6 -0
- mistralai/models/conversationhistory.py +4 -4
- mistralai/models/conversationrequest.py +1 -1
- mistralai/models/conversationstreamrequest.py +1 -1
- mistralai/models/conversationusageinfo.py +1 -1
- mistralai/models/deltamessage.py +1 -1
- mistralai/models/documentout.py +105 -0
- mistralai/models/documenttextcontent.py +13 -0
- mistralai/models/documentupdatein.py +44 -0
- mistralai/models/documenturlchunk.py +1 -1
- mistralai/models/embeddingrequest.py +1 -1
- mistralai/models/entitytype.py +9 -0
- mistralai/models/eventout.py +1 -1
- mistralai/models/file.py +33 -0
- mistralai/models/filechunk.py +23 -0
- mistralai/models/files_api_routes_list_filesop.py +1 -1
- mistralai/models/files_api_routes_upload_fileop.py +2 -27
- mistralai/models/fileschema.py +1 -1
- mistralai/models/fimcompletionrequest.py +1 -1
- mistralai/models/fimcompletionstreamrequest.py +1 -1
- mistralai/models/ftmodelcard.py +6 -1
- mistralai/models/functioncallentry.py +1 -1
- mistralai/models/functionresultentry.py +1 -1
- mistralai/models/githubrepositoryin.py +1 -1
- mistralai/models/githubrepositoryout.py +1 -1
- mistralai/models/imageurl.py +1 -1
- mistralai/models/inputentries.py +21 -2
- mistralai/models/jobin.py +1 -1
- mistralai/models/jobmetadataout.py +1 -1
- mistralai/models/jobs_api_routes_batch_get_batch_jobsop.py +1 -1
- mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +1 -1
- mistralai/models/jsonschema.py +1 -1
- mistralai/models/legacyjobmetadataout.py +1 -1
- mistralai/models/libraries_delete_v1op.py +16 -0
- mistralai/models/libraries_documents_delete_v1op.py +21 -0
- mistralai/models/libraries_documents_get_extracted_text_signed_url_v1op.py +21 -0
- mistralai/models/libraries_documents_get_signed_url_v1op.py +21 -0
- mistralai/models/libraries_documents_get_status_v1op.py +21 -0
- mistralai/models/libraries_documents_get_text_content_v1op.py +21 -0
- mistralai/models/libraries_documents_get_v1op.py +21 -0
- mistralai/models/libraries_documents_list_v1op.py +78 -0
- mistralai/models/libraries_documents_reprocess_v1op.py +21 -0
- mistralai/models/libraries_documents_update_v1op.py +28 -0
- mistralai/models/libraries_documents_upload_v1op.py +56 -0
- mistralai/models/libraries_get_v1op.py +16 -0
- mistralai/models/libraries_share_create_v1op.py +22 -0
- mistralai/models/libraries_share_delete_v1op.py +23 -0
- mistralai/models/libraries_share_list_v1op.py +16 -0
- mistralai/models/libraries_update_v1op.py +23 -0
- mistralai/models/libraryin.py +50 -0
- mistralai/models/libraryinupdate.py +47 -0
- mistralai/models/libraryout.py +107 -0
- mistralai/models/listdocumentout.py +19 -0
- mistralai/models/listlibraryout.py +15 -0
- mistralai/models/listsharingout.py +15 -0
- mistralai/models/messageinputentry.py +12 -2
- mistralai/models/messageoutputentry.py +1 -1
- mistralai/models/messageoutputevent.py +1 -1
- mistralai/models/metricout.py +1 -1
- mistralai/models/modelcapabilities.py +3 -0
- mistralai/models/modelconversation.py +1 -1
- mistralai/models/ocrimageobject.py +1 -1
- mistralai/models/ocrpageobject.py +1 -1
- mistralai/models/ocrrequest.py +5 -3
- mistralai/models/ocrresponse.py +1 -1
- mistralai/models/ocrusageinfo.py +1 -1
- mistralai/models/paginationinfo.py +25 -0
- mistralai/models/processingstatusout.py +16 -0
- mistralai/models/responseformat.py +1 -1
- mistralai/models/retrievefileout.py +1 -1
- mistralai/models/shareenum.py +8 -0
- mistralai/models/sharingdelete.py +26 -0
- mistralai/models/sharingin.py +30 -0
- mistralai/models/sharingout.py +59 -0
- mistralai/models/ssetypes.py +1 -0
- mistralai/models/toolexecutiondeltaevent.py +34 -0
- mistralai/models/toolexecutionentry.py +4 -1
- mistralai/models/toolexecutionstartedevent.py +3 -0
- mistralai/models/toolfilechunk.py +1 -1
- mistralai/models/toolmessage.py +1 -1
- mistralai/models/toolreferencechunk.py +8 -5
- mistralai/models/updateftmodelin.py +1 -1
- mistralai/models/uploadfileout.py +1 -1
- mistralai/models/usermessage.py +1 -1
- mistralai/models/wandbintegration.py +1 -1
- mistralai/models/wandbintegrationout.py +1 -1
- mistralai/models_.py +14 -2
- mistralai/ocr.py +2 -0
- mistralai/sdk.py +68 -40
- mistralai/sdkconfiguration.py +0 -7
- mistralai/types/basemodel.py +3 -3
- mistralai/utils/__init__.py +131 -45
- mistralai/utils/datetimes.py +23 -0
- mistralai/utils/enums.py +67 -27
- mistralai/utils/forms.py +49 -28
- mistralai/utils/serializers.py +32 -3
- {mistralai-1.8.2.dist-info → mistralai-1.9.2.dist-info}/METADATA +41 -7
- {mistralai-1.8.2.dist-info → mistralai-1.9.2.dist-info}/RECORD +152 -113
- {mistralai-1.8.2.dist-info → mistralai-1.9.2.dist-info}/LICENSE +0 -0
- {mistralai-1.8.2.dist-info → mistralai-1.9.2.dist-info}/WHEEL +0 -0
mistralai/types/basemodel.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from pydantic import ConfigDict, model_serializer
|
|
4
4
|
from pydantic import BaseModel as PydanticBaseModel
|
|
5
|
-
from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union
|
|
5
|
+
from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union
|
|
6
6
|
from typing_extensions import TypeAliasType, TypeAlias
|
|
7
7
|
|
|
8
8
|
|
|
@@ -35,5 +35,5 @@ else:
|
|
|
35
35
|
"OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
|
|
36
36
|
)
|
|
37
37
|
|
|
38
|
-
UnrecognizedInt =
|
|
39
|
-
UnrecognizedStr =
|
|
38
|
+
UnrecognizedInt: TypeAlias = int
|
|
39
|
+
UnrecognizedStr: TypeAlias = str
|
mistralai/utils/__init__.py
CHANGED
|
@@ -1,51 +1,56 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from
|
|
5
|
-
from .headers import get_headers, get_response_headers
|
|
6
|
-
from .metadata import (
|
|
7
|
-
FieldMetadata,
|
|
8
|
-
find_metadata,
|
|
9
|
-
FormMetadata,
|
|
10
|
-
HeaderMetadata,
|
|
11
|
-
MultipartFormMetadata,
|
|
12
|
-
PathParamMetadata,
|
|
13
|
-
QueryParamMetadata,
|
|
14
|
-
RequestMetadata,
|
|
15
|
-
SecurityMetadata,
|
|
16
|
-
)
|
|
17
|
-
from .queryparams import get_query_params
|
|
18
|
-
from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig
|
|
19
|
-
from .requestbodies import serialize_request_body, SerializedRequestBody
|
|
20
|
-
from .security import get_security, get_security_from_env
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
from importlib import import_module
|
|
21
5
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
from .
|
|
41
|
-
from .
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from .annotations import get_discriminator
|
|
8
|
+
from .datetimes import parse_datetime
|
|
9
|
+
from .enums import OpenEnumMeta
|
|
10
|
+
from .headers import get_headers, get_response_headers
|
|
11
|
+
from .metadata import (
|
|
12
|
+
FieldMetadata,
|
|
13
|
+
find_metadata,
|
|
14
|
+
FormMetadata,
|
|
15
|
+
HeaderMetadata,
|
|
16
|
+
MultipartFormMetadata,
|
|
17
|
+
PathParamMetadata,
|
|
18
|
+
QueryParamMetadata,
|
|
19
|
+
RequestMetadata,
|
|
20
|
+
SecurityMetadata,
|
|
21
|
+
)
|
|
22
|
+
from .queryparams import get_query_params
|
|
23
|
+
from .retries import BackoffStrategy, Retries, retry, retry_async, RetryConfig
|
|
24
|
+
from .requestbodies import serialize_request_body, SerializedRequestBody
|
|
25
|
+
from .security import get_security, get_security_from_env
|
|
26
|
+
|
|
27
|
+
from .serializers import (
|
|
28
|
+
get_pydantic_model,
|
|
29
|
+
marshal_json,
|
|
30
|
+
unmarshal,
|
|
31
|
+
unmarshal_json,
|
|
32
|
+
serialize_decimal,
|
|
33
|
+
serialize_float,
|
|
34
|
+
serialize_int,
|
|
35
|
+
stream_to_text,
|
|
36
|
+
stream_to_text_async,
|
|
37
|
+
stream_to_bytes,
|
|
38
|
+
stream_to_bytes_async,
|
|
39
|
+
validate_const,
|
|
40
|
+
validate_decimal,
|
|
41
|
+
validate_float,
|
|
42
|
+
validate_int,
|
|
43
|
+
validate_open_enum,
|
|
44
|
+
)
|
|
45
|
+
from .url import generate_url, template_url, remove_suffix
|
|
46
|
+
from .values import (
|
|
47
|
+
get_global_from_env,
|
|
48
|
+
match_content_type,
|
|
49
|
+
match_status_codes,
|
|
50
|
+
match_response,
|
|
51
|
+
cast_partial,
|
|
52
|
+
)
|
|
53
|
+
from .logger import Logger, get_body_content, get_default_logger
|
|
49
54
|
|
|
50
55
|
__all__ = [
|
|
51
56
|
"BackoffStrategy",
|
|
@@ -56,6 +61,7 @@ __all__ = [
|
|
|
56
61
|
"get_body_content",
|
|
57
62
|
"get_default_logger",
|
|
58
63
|
"get_discriminator",
|
|
64
|
+
"parse_datetime",
|
|
59
65
|
"get_global_from_env",
|
|
60
66
|
"get_headers",
|
|
61
67
|
"get_pydantic_model",
|
|
@@ -99,3 +105,83 @@ __all__ = [
|
|
|
99
105
|
"validate_open_enum",
|
|
100
106
|
"cast_partial",
|
|
101
107
|
]
|
|
108
|
+
|
|
109
|
+
_dynamic_imports: dict[str, str] = {
|
|
110
|
+
"BackoffStrategy": ".retries",
|
|
111
|
+
"FieldMetadata": ".metadata",
|
|
112
|
+
"find_metadata": ".metadata",
|
|
113
|
+
"FormMetadata": ".metadata",
|
|
114
|
+
"generate_url": ".url",
|
|
115
|
+
"get_body_content": ".logger",
|
|
116
|
+
"get_default_logger": ".logger",
|
|
117
|
+
"get_discriminator": ".annotations",
|
|
118
|
+
"parse_datetime": ".datetimes",
|
|
119
|
+
"get_global_from_env": ".values",
|
|
120
|
+
"get_headers": ".headers",
|
|
121
|
+
"get_pydantic_model": ".serializers",
|
|
122
|
+
"get_query_params": ".queryparams",
|
|
123
|
+
"get_response_headers": ".headers",
|
|
124
|
+
"get_security": ".security",
|
|
125
|
+
"get_security_from_env": ".security",
|
|
126
|
+
"HeaderMetadata": ".metadata",
|
|
127
|
+
"Logger": ".logger",
|
|
128
|
+
"marshal_json": ".serializers",
|
|
129
|
+
"match_content_type": ".values",
|
|
130
|
+
"match_status_codes": ".values",
|
|
131
|
+
"match_response": ".values",
|
|
132
|
+
"MultipartFormMetadata": ".metadata",
|
|
133
|
+
"OpenEnumMeta": ".enums",
|
|
134
|
+
"PathParamMetadata": ".metadata",
|
|
135
|
+
"QueryParamMetadata": ".metadata",
|
|
136
|
+
"remove_suffix": ".url",
|
|
137
|
+
"Retries": ".retries",
|
|
138
|
+
"retry": ".retries",
|
|
139
|
+
"retry_async": ".retries",
|
|
140
|
+
"RetryConfig": ".retries",
|
|
141
|
+
"RequestMetadata": ".metadata",
|
|
142
|
+
"SecurityMetadata": ".metadata",
|
|
143
|
+
"serialize_decimal": ".serializers",
|
|
144
|
+
"serialize_float": ".serializers",
|
|
145
|
+
"serialize_int": ".serializers",
|
|
146
|
+
"serialize_request_body": ".requestbodies",
|
|
147
|
+
"SerializedRequestBody": ".requestbodies",
|
|
148
|
+
"stream_to_text": ".serializers",
|
|
149
|
+
"stream_to_text_async": ".serializers",
|
|
150
|
+
"stream_to_bytes": ".serializers",
|
|
151
|
+
"stream_to_bytes_async": ".serializers",
|
|
152
|
+
"template_url": ".url",
|
|
153
|
+
"unmarshal": ".serializers",
|
|
154
|
+
"unmarshal_json": ".serializers",
|
|
155
|
+
"validate_decimal": ".serializers",
|
|
156
|
+
"validate_const": ".serializers",
|
|
157
|
+
"validate_float": ".serializers",
|
|
158
|
+
"validate_int": ".serializers",
|
|
159
|
+
"validate_open_enum": ".serializers",
|
|
160
|
+
"cast_partial": ".values",
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def __getattr__(attr_name: str) -> object:
|
|
165
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
166
|
+
if module_name is None:
|
|
167
|
+
raise AttributeError(
|
|
168
|
+
f"no {attr_name} found in _dynamic_imports, module name -> {__name__} "
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
try:
|
|
172
|
+
module = import_module(module_name, __package__)
|
|
173
|
+
result = getattr(module, attr_name)
|
|
174
|
+
return result
|
|
175
|
+
except ImportError as e:
|
|
176
|
+
raise ImportError(
|
|
177
|
+
f"Failed to import {attr_name} from {module_name}: {e}"
|
|
178
|
+
) from e
|
|
179
|
+
except AttributeError as e:
|
|
180
|
+
raise AttributeError(
|
|
181
|
+
f"Failed to get {attr_name} from {module_name}: {e}"
|
|
182
|
+
) from e
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def __dir__():
|
|
186
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
187
|
+
return sorted(lazy_attrs)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def parse_datetime(datetime_string: str) -> datetime:
|
|
8
|
+
"""
|
|
9
|
+
Convert a RFC 3339 / ISO 8601 formatted string into a datetime object.
|
|
10
|
+
Python versions 3.11 and later support parsing RFC 3339 directly with
|
|
11
|
+
datetime.fromisoformat(), but for earlier versions, this function
|
|
12
|
+
encapsulates the necessary extra logic.
|
|
13
|
+
"""
|
|
14
|
+
# Python 3.11 and later can parse RFC 3339 directly
|
|
15
|
+
if sys.version_info >= (3, 11):
|
|
16
|
+
return datetime.fromisoformat(datetime_string)
|
|
17
|
+
|
|
18
|
+
# For Python 3.10 and earlier, a common ValueError is trailing 'Z' suffix,
|
|
19
|
+
# so fix that upfront.
|
|
20
|
+
if datetime_string.endswith("Z"):
|
|
21
|
+
datetime_string = datetime_string[:-1] + "+00:00"
|
|
22
|
+
|
|
23
|
+
return datetime.fromisoformat(datetime_string)
|
mistralai/utils/enums.py
CHANGED
|
@@ -1,34 +1,74 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
import enum
|
|
4
|
-
|
|
4
|
+
import sys
|
|
5
5
|
|
|
6
6
|
class OpenEnumMeta(enum.EnumMeta):
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
# The __call__ method `boundary` kwarg was added in 3.11 and must be present
|
|
8
|
+
# for pyright. Refer also: https://github.com/pylint-dev/pylint/issues/9622
|
|
9
|
+
# pylint: disable=unexpected-keyword-arg
|
|
10
|
+
# The __call__ method `values` varg must be named for pyright.
|
|
11
|
+
# pylint: disable=keyword-arg-before-vararg
|
|
12
|
+
|
|
13
|
+
if sys.version_info >= (3, 11):
|
|
14
|
+
def __call__(
|
|
15
|
+
cls, value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None
|
|
16
|
+
):
|
|
17
|
+
# The `type` kwarg also happens to be a built-in that pylint flags as
|
|
18
|
+
# redeclared. Safe to ignore this lint rule with this scope.
|
|
19
|
+
# pylint: disable=redefined-builtin
|
|
20
|
+
|
|
21
|
+
if names is not None:
|
|
22
|
+
return super().__call__(
|
|
23
|
+
value,
|
|
24
|
+
names=names,
|
|
25
|
+
*values,
|
|
26
|
+
module=module,
|
|
27
|
+
qualname=qualname,
|
|
28
|
+
type=type,
|
|
29
|
+
start=start,
|
|
30
|
+
boundary=boundary,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
return super().__call__(
|
|
35
|
+
value,
|
|
36
|
+
names=names, # pyright: ignore[reportArgumentType]
|
|
37
|
+
*values,
|
|
38
|
+
module=module,
|
|
39
|
+
qualname=qualname,
|
|
40
|
+
type=type,
|
|
41
|
+
start=start,
|
|
42
|
+
boundary=boundary,
|
|
43
|
+
)
|
|
44
|
+
except ValueError:
|
|
45
|
+
return value
|
|
46
|
+
else:
|
|
47
|
+
def __call__(
|
|
48
|
+
cls, value, names=None, *, module=None, qualname=None, type=None, start=1
|
|
49
|
+
):
|
|
50
|
+
# The `type` kwarg also happens to be a built-in that pylint flags as
|
|
51
|
+
# redeclared. Safe to ignore this lint rule with this scope.
|
|
52
|
+
# pylint: disable=redefined-builtin
|
|
13
53
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
54
|
+
if names is not None:
|
|
55
|
+
return super().__call__(
|
|
56
|
+
value,
|
|
57
|
+
names=names,
|
|
58
|
+
module=module,
|
|
59
|
+
qualname=qualname,
|
|
60
|
+
type=type,
|
|
61
|
+
start=start,
|
|
62
|
+
)
|
|
23
63
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
64
|
+
try:
|
|
65
|
+
return super().__call__(
|
|
66
|
+
value,
|
|
67
|
+
names=names, # pyright: ignore[reportArgumentType]
|
|
68
|
+
module=module,
|
|
69
|
+
qualname=qualname,
|
|
70
|
+
type=type,
|
|
71
|
+
start=start,
|
|
72
|
+
)
|
|
73
|
+
except ValueError:
|
|
74
|
+
return value
|
mistralai/utils/forms.py
CHANGED
|
@@ -86,11 +86,39 @@ def _populate_form(
|
|
|
86
86
|
return form
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
def _extract_file_properties(file_obj: Any) -> Tuple[str, Any, Any]:
|
|
90
|
+
"""Extract file name, content, and content type from a file object."""
|
|
91
|
+
file_fields: Dict[str, FieldInfo] = file_obj.__class__.model_fields
|
|
92
|
+
|
|
93
|
+
file_name = ""
|
|
94
|
+
content = None
|
|
95
|
+
content_type = None
|
|
96
|
+
|
|
97
|
+
for file_field_name in file_fields:
|
|
98
|
+
file_field = file_fields[file_field_name]
|
|
99
|
+
|
|
100
|
+
file_metadata = find_field_metadata(file_field, MultipartFormMetadata)
|
|
101
|
+
if file_metadata is None:
|
|
102
|
+
continue
|
|
103
|
+
|
|
104
|
+
if file_metadata.content:
|
|
105
|
+
content = getattr(file_obj, file_field_name, None)
|
|
106
|
+
elif file_field_name == "content_type":
|
|
107
|
+
content_type = getattr(file_obj, file_field_name, None)
|
|
108
|
+
else:
|
|
109
|
+
file_name = getattr(file_obj, file_field_name)
|
|
110
|
+
|
|
111
|
+
if file_name == "" or content is None:
|
|
112
|
+
raise ValueError("invalid multipart/form-data file")
|
|
113
|
+
|
|
114
|
+
return file_name, content, content_type
|
|
115
|
+
|
|
116
|
+
|
|
89
117
|
def serialize_multipart_form(
|
|
90
118
|
media_type: str, request: Any
|
|
91
|
-
) -> Tuple[str, Dict[str, Any],
|
|
119
|
+
) -> Tuple[str, Dict[str, Any], List[Tuple[str, Any]]]:
|
|
92
120
|
form: Dict[str, Any] = {}
|
|
93
|
-
files:
|
|
121
|
+
files: List[Tuple[str, Any]] = []
|
|
94
122
|
|
|
95
123
|
if not isinstance(request, BaseModel):
|
|
96
124
|
raise TypeError("invalid request body type")
|
|
@@ -112,39 +140,32 @@ def serialize_multipart_form(
|
|
|
112
140
|
f_name = field.alias if field.alias else name
|
|
113
141
|
|
|
114
142
|
if field_metadata.file:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
file_field = file_fields[file_field_name]
|
|
143
|
+
if isinstance(val, List):
|
|
144
|
+
# Handle array of files
|
|
145
|
+
for file_obj in val:
|
|
146
|
+
if not _is_set(file_obj):
|
|
147
|
+
continue
|
|
148
|
+
|
|
149
|
+
file_name, content, content_type = _extract_file_properties(file_obj)
|
|
123
150
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
151
|
+
if content_type is not None:
|
|
152
|
+
files.append((f_name + "[]", (file_name, content, content_type)))
|
|
153
|
+
else:
|
|
154
|
+
files.append((f_name + "[]", (file_name, content)))
|
|
155
|
+
else:
|
|
156
|
+
# Handle single file
|
|
157
|
+
file_name, content, content_type = _extract_file_properties(val)
|
|
127
158
|
|
|
128
|
-
if
|
|
129
|
-
|
|
130
|
-
elif file_field_name == "content_type":
|
|
131
|
-
content_type = getattr(val, file_field_name, None)
|
|
159
|
+
if content_type is not None:
|
|
160
|
+
files.append((f_name, (file_name, content, content_type)))
|
|
132
161
|
else:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if file_name == "" or content is None:
|
|
136
|
-
raise ValueError("invalid multipart/form-data file")
|
|
137
|
-
|
|
138
|
-
if content_type is not None:
|
|
139
|
-
files[f_name] = (file_name, content, content_type)
|
|
140
|
-
else:
|
|
141
|
-
files[f_name] = (file_name, content)
|
|
162
|
+
files.append((f_name, (file_name, content)))
|
|
142
163
|
elif field_metadata.json:
|
|
143
|
-
files
|
|
164
|
+
files.append((f_name, (
|
|
144
165
|
None,
|
|
145
166
|
marshal_json(val, request_field_types[name]),
|
|
146
167
|
"application/json",
|
|
147
|
-
)
|
|
168
|
+
)))
|
|
148
169
|
else:
|
|
149
170
|
if isinstance(val, List):
|
|
150
171
|
values = []
|
mistralai/utils/serializers.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from decimal import Decimal
|
|
4
|
+
import functools
|
|
4
5
|
import json
|
|
5
|
-
|
|
6
|
-
import
|
|
6
|
+
import typing
|
|
7
|
+
from typing import Any, Dict, List, Tuple, Union, get_args
|
|
8
|
+
import typing_extensions
|
|
7
9
|
from typing_extensions import get_origin
|
|
10
|
+
|
|
11
|
+
import httpx
|
|
8
12
|
from pydantic import ConfigDict, create_model
|
|
9
13
|
from pydantic_core import from_json
|
|
10
|
-
from typing_inspection.typing_objects import is_union
|
|
11
14
|
|
|
12
15
|
from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset
|
|
13
16
|
|
|
@@ -185,6 +188,13 @@ def is_nullable(field):
|
|
|
185
188
|
return False
|
|
186
189
|
|
|
187
190
|
|
|
191
|
+
def is_union(obj: object) -> bool:
|
|
192
|
+
"""
|
|
193
|
+
Returns True if the given object is a typing.Union or typing_extensions.Union.
|
|
194
|
+
"""
|
|
195
|
+
return any(obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union"))
|
|
196
|
+
|
|
197
|
+
|
|
188
198
|
def stream_to_text(stream: httpx.Response) -> str:
|
|
189
199
|
return "".join(stream.iter_text())
|
|
190
200
|
|
|
@@ -217,3 +227,22 @@ def _contains_pydantic_model(data: Any) -> bool:
|
|
|
217
227
|
return any(_contains_pydantic_model(value) for value in data.values())
|
|
218
228
|
|
|
219
229
|
return False
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@functools.cache
|
|
233
|
+
def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]:
|
|
234
|
+
"""
|
|
235
|
+
Get typing objects by name from typing and typing_extensions.
|
|
236
|
+
Reference: https://typing-extensions.readthedocs.io/en/latest/#runtime-use-of-types
|
|
237
|
+
"""
|
|
238
|
+
result = tuple(
|
|
239
|
+
getattr(module, name)
|
|
240
|
+
for module in (typing, typing_extensions)
|
|
241
|
+
if hasattr(module, name)
|
|
242
|
+
)
|
|
243
|
+
if not result:
|
|
244
|
+
raise ValueError(
|
|
245
|
+
f"Neither typing nor typing_extensions has an object called {name!r}"
|
|
246
|
+
)
|
|
247
|
+
return result
|
|
248
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: mistralai
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.9.2
|
|
4
4
|
Summary: Python Client SDK for the Mistral AI API.
|
|
5
5
|
Author: Mistral
|
|
6
6
|
Requires-Python: >=3.9
|
|
@@ -169,7 +169,7 @@ with Mistral(
|
|
|
169
169
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
170
170
|
"role": "user",
|
|
171
171
|
},
|
|
172
|
-
])
|
|
172
|
+
], stream=False)
|
|
173
173
|
|
|
174
174
|
# Handle response
|
|
175
175
|
print(res)
|
|
@@ -195,7 +195,7 @@ async def main():
|
|
|
195
195
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
196
196
|
"role": "user",
|
|
197
197
|
},
|
|
198
|
-
])
|
|
198
|
+
], stream=False)
|
|
199
199
|
|
|
200
200
|
# Handle response
|
|
201
201
|
print(res)
|
|
@@ -271,7 +271,7 @@ with Mistral(
|
|
|
271
271
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
272
272
|
"role": "user",
|
|
273
273
|
},
|
|
274
|
-
], agent_id="<id>")
|
|
274
|
+
], agent_id="<id>", stream=False)
|
|
275
275
|
|
|
276
276
|
# Handle response
|
|
277
277
|
print(res)
|
|
@@ -297,7 +297,7 @@ async def main():
|
|
|
297
297
|
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
298
298
|
"role": "user",
|
|
299
299
|
},
|
|
300
|
-
], agent_id="<id>")
|
|
300
|
+
], agent_id="<id>", stream=False)
|
|
301
301
|
|
|
302
302
|
# Handle response
|
|
303
303
|
print(res)
|
|
@@ -495,6 +495,33 @@ The documentation for the GCP SDK is available [here](https://github.com/mistral
|
|
|
495
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
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
497
|
|
|
498
|
+
#### [beta.libraries](https://github.com/mistralai/client-python/blob/master/docs/sdks/libraries/README.md)
|
|
499
|
+
|
|
500
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/libraries/README.md#list) - List all libraries you have access to.
|
|
501
|
+
* [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/libraries/README.md#create) - Create a new Library.
|
|
502
|
+
* [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/libraries/README.md#get) - Detailed information about a specific Library.
|
|
503
|
+
* [delete](https://github.com/mistralai/client-python/blob/master/docs/sdks/libraries/README.md#delete) - Delete a library and all of it's document.
|
|
504
|
+
* [update](https://github.com/mistralai/client-python/blob/master/docs/sdks/libraries/README.md#update) - Update a library.
|
|
505
|
+
|
|
506
|
+
#### [beta.libraries.accesses](https://github.com/mistralai/client-python/blob/master/docs/sdks/accesses/README.md)
|
|
507
|
+
|
|
508
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/accesses/README.md#list) - List all of the access to this library.
|
|
509
|
+
* [update_or_create](https://github.com/mistralai/client-python/blob/master/docs/sdks/accesses/README.md#update_or_create) - Create or update an access level.
|
|
510
|
+
* [delete](https://github.com/mistralai/client-python/blob/master/docs/sdks/accesses/README.md#delete) - Delete an access level.
|
|
511
|
+
|
|
512
|
+
#### [beta.libraries.documents](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md)
|
|
513
|
+
|
|
514
|
+
* [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#list) - List document in a given library.
|
|
515
|
+
* [upload](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#upload) - Upload a new document.
|
|
516
|
+
* [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#get) - Retrieve the metadata of a specific document.
|
|
517
|
+
* [update](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#update) - Update the metadata of a specific document.
|
|
518
|
+
* [delete](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#delete) - Delete a document.
|
|
519
|
+
* [text_content](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#text_content) - Retrieve the text content of a specific document.
|
|
520
|
+
* [status](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#status) - Retrieve the processing status of a specific document.
|
|
521
|
+
* [get_signed_url](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#get_signed_url) - Retrieve the signed URL of a specific document.
|
|
522
|
+
* [extracted_text_signed_url](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#extracted_text_signed_url) - Retrieve the signed URL of text extracted from a given document.
|
|
523
|
+
* [reprocess](https://github.com/mistralai/client-python/blob/master/docs/sdks/documents/README.md#reprocess) - Reprocess a document.
|
|
524
|
+
|
|
498
525
|
### [chat](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md)
|
|
499
526
|
|
|
500
527
|
* [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md#complete) - Chat Completion
|
|
@@ -574,7 +601,14 @@ with Mistral(
|
|
|
574
601
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
575
602
|
) as mistral:
|
|
576
603
|
|
|
577
|
-
res = mistral.beta.conversations.start_stream(inputs=
|
|
604
|
+
res = mistral.beta.conversations.start_stream(inputs=[
|
|
605
|
+
{
|
|
606
|
+
"object": "entry",
|
|
607
|
+
"type": "function.result",
|
|
608
|
+
"tool_call_id": "<id>",
|
|
609
|
+
"result": "<value>",
|
|
610
|
+
},
|
|
611
|
+
], stream=True)
|
|
578
612
|
|
|
579
613
|
with res as event_stream:
|
|
580
614
|
for event in event_stream:
|
|
@@ -607,7 +641,7 @@ with Mistral(
|
|
|
607
641
|
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
608
642
|
) as mistral:
|
|
609
643
|
|
|
610
|
-
res = mistral.
|
|
644
|
+
res = mistral.beta.libraries.documents.upload(library_id="a02150d9-5ee0-4877-b62c-28b1fcdf3b76", file={
|
|
611
645
|
"file_name": "example.file",
|
|
612
646
|
"content": open("example.file", "rb"),
|
|
613
647
|
})
|