mistralai 1.2.3__py3-none-any.whl → 1.2.4__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 +1 -1
- mistralai/agents.py +5 -5
- mistralai/chat.py +5 -5
- mistralai/files.py +166 -0
- mistralai/fim.py +5 -5
- mistralai/httpclient.py +6 -0
- mistralai/jobs.py +2 -2
- mistralai/models/__init__.py +9 -2
- mistralai/models/agentscompletionrequest.py +23 -11
- mistralai/models/agentscompletionstreamrequest.py +23 -13
- mistralai/models/apiendpoint.py +11 -3
- mistralai/models/assistantmessage.py +7 -3
- mistralai/models/batchjobin.py +4 -2
- mistralai/models/chatclassificationrequest.py +26 -17
- mistralai/models/chatcompletionrequest.py +19 -11
- mistralai/models/chatcompletionstreamrequest.py +23 -13
- mistralai/models/classificationrequest.py +7 -3
- mistralai/models/contentchunk.py +5 -4
- mistralai/models/deltamessage.py +5 -3
- mistralai/models/detailedjobout.py +2 -3
- mistralai/models/embeddingrequest.py +3 -3
- mistralai/models/files_api_routes_get_signed_urlop.py +25 -0
- mistralai/models/filesignedurl.py +13 -0
- mistralai/models/fimcompletionrequest.py +7 -3
- mistralai/models/fimcompletionstreamrequest.py +7 -3
- mistralai/models/functioncall.py +3 -3
- mistralai/models/imageurlchunk.py +9 -14
- mistralai/models/jobin.py +2 -3
- mistralai/models/jobout.py +2 -3
- mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +9 -4
- mistralai/models/modellist.py +4 -2
- mistralai/models/referencechunk.py +3 -11
- mistralai/models/retrieve_model_v1_models_model_id_getop.py +5 -4
- mistralai/models/systemmessage.py +7 -3
- mistralai/models/textchunk.py +3 -9
- mistralai/models/toolmessage.py +5 -3
- mistralai/models/usermessage.py +5 -3
- mistralai/models/validationerror.py +3 -3
- mistralai/sdk.py +14 -0
- mistralai/sdkconfiguration.py +3 -3
- mistralai/utils/annotations.py +42 -17
- mistralai/utils/eventstreaming.py +61 -1
- {mistralai-1.2.3.dist-info → mistralai-1.2.4.dist-info}/METADATA +181 -176
- {mistralai-1.2.3.dist-info → mistralai-1.2.4.dist-info}/RECORD +84 -83
- mistralai_azure/chat.py +5 -5
- mistralai_azure/httpclient.py +6 -0
- mistralai_azure/models/assistantmessage.py +7 -3
- mistralai_azure/models/chatcompletionrequest.py +23 -11
- mistralai_azure/models/chatcompletionstreamrequest.py +19 -13
- mistralai_azure/models/contentchunk.py +4 -2
- mistralai_azure/models/deltamessage.py +5 -3
- mistralai_azure/models/functioncall.py +3 -3
- mistralai_azure/models/referencechunk.py +3 -11
- mistralai_azure/models/systemmessage.py +7 -3
- mistralai_azure/models/textchunk.py +3 -9
- mistralai_azure/models/toolmessage.py +5 -3
- mistralai_azure/models/usermessage.py +5 -3
- mistralai_azure/models/validationerror.py +3 -3
- mistralai_azure/sdkconfiguration.py +2 -2
- mistralai_azure/utils/annotations.py +42 -17
- mistralai_azure/utils/eventstreaming.py +61 -1
- mistralai_gcp/chat.py +5 -5
- mistralai_gcp/fim.py +5 -5
- mistralai_gcp/httpclient.py +6 -0
- mistralai_gcp/models/assistantmessage.py +7 -3
- mistralai_gcp/models/chatcompletionrequest.py +23 -11
- mistralai_gcp/models/chatcompletionstreamrequest.py +19 -13
- mistralai_gcp/models/contentchunk.py +4 -2
- mistralai_gcp/models/deltamessage.py +5 -3
- mistralai_gcp/models/fimcompletionrequest.py +7 -3
- mistralai_gcp/models/fimcompletionstreamrequest.py +7 -3
- mistralai_gcp/models/functioncall.py +3 -3
- mistralai_gcp/models/referencechunk.py +3 -11
- mistralai_gcp/models/systemmessage.py +7 -3
- mistralai_gcp/models/textchunk.py +3 -9
- mistralai_gcp/models/toolmessage.py +5 -3
- mistralai_gcp/models/usermessage.py +5 -3
- mistralai_gcp/models/validationerror.py +3 -3
- mistralai_gcp/sdk.py +5 -4
- mistralai_gcp/sdkconfiguration.py +2 -2
- mistralai_gcp/utils/annotations.py +42 -17
- mistralai_gcp/utils/eventstreaming.py +61 -1
- mistralai/models/finetuneablemodel.py +0 -14
- {mistralai-1.2.3.dist-info → mistralai-1.2.4.dist-info}/LICENSE +0 -0
- {mistralai-1.2.3.dist-info → mistralai-1.2.4.dist-info}/WHEEL +0 -0
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai_gcp.types import BaseModel
|
|
5
|
-
from mistralai_gcp.utils import validate_const
|
|
6
|
-
import pydantic
|
|
7
|
-
from pydantic.functional_validators import AfterValidator
|
|
8
5
|
from typing import Literal, Optional
|
|
9
|
-
from typing_extensions import
|
|
6
|
+
from typing_extensions import NotRequired, TypedDict
|
|
10
7
|
|
|
11
8
|
|
|
12
9
|
Type = Literal["text"]
|
|
@@ -14,13 +11,10 @@ Type = Literal["text"]
|
|
|
14
11
|
|
|
15
12
|
class TextChunkTypedDict(TypedDict):
|
|
16
13
|
text: str
|
|
17
|
-
type: Type
|
|
14
|
+
type: NotRequired[Type]
|
|
18
15
|
|
|
19
16
|
|
|
20
17
|
class TextChunk(BaseModel):
|
|
21
18
|
text: str
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
Annotated[Optional[Type], AfterValidator(validate_const("text"))],
|
|
25
|
-
pydantic.Field(alias="type"),
|
|
26
|
-
] = "text"
|
|
20
|
+
type: Optional[Type] = "text"
|
|
@@ -11,13 +11,15 @@ from mistralai_gcp.types import (
|
|
|
11
11
|
)
|
|
12
12
|
from pydantic import model_serializer
|
|
13
13
|
from typing import List, Literal, Optional, Union
|
|
14
|
-
from typing_extensions import NotRequired, TypedDict
|
|
14
|
+
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
ToolMessageContentTypedDict =
|
|
17
|
+
ToolMessageContentTypedDict = TypeAliasType(
|
|
18
|
+
"ToolMessageContentTypedDict", Union[str, List[ContentChunkTypedDict]]
|
|
19
|
+
)
|
|
18
20
|
|
|
19
21
|
|
|
20
|
-
ToolMessageContent = Union[str, List[ContentChunk]]
|
|
22
|
+
ToolMessageContent = TypeAliasType("ToolMessageContent", Union[str, List[ContentChunk]])
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
ToolMessageRole = Literal["tool"]
|
|
@@ -5,13 +5,15 @@ from .contentchunk import ContentChunk, ContentChunkTypedDict
|
|
|
5
5
|
from mistralai_gcp.types import BaseModel, Nullable, UNSET_SENTINEL
|
|
6
6
|
from pydantic import model_serializer
|
|
7
7
|
from typing import List, Literal, Optional, Union
|
|
8
|
-
from typing_extensions import NotRequired, TypedDict
|
|
8
|
+
from typing_extensions import NotRequired, TypeAliasType, TypedDict
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
UserMessageContentTypedDict =
|
|
11
|
+
UserMessageContentTypedDict = TypeAliasType(
|
|
12
|
+
"UserMessageContentTypedDict", Union[str, List[ContentChunkTypedDict]]
|
|
13
|
+
)
|
|
12
14
|
|
|
13
15
|
|
|
14
|
-
UserMessageContent = Union[str, List[ContentChunk]]
|
|
16
|
+
UserMessageContent = TypeAliasType("UserMessageContent", Union[str, List[ContentChunk]])
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
UserMessageRole = Literal["user"]
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
from mistralai_gcp.types import BaseModel
|
|
5
5
|
from typing import List, Union
|
|
6
|
-
from typing_extensions import TypedDict
|
|
6
|
+
from typing_extensions import TypeAliasType, TypedDict
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
LocTypedDict = Union[str, int]
|
|
9
|
+
LocTypedDict = TypeAliasType("LocTypedDict", Union[str, int])
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
Loc = Union[str, int]
|
|
12
|
+
Loc = TypeAliasType("Loc", Union[str, int])
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
class ValidationErrorTypedDict(TypedDict):
|
mistralai_gcp/sdk.py
CHANGED
|
@@ -26,11 +26,12 @@ LEGACY_MODEL_ID_FORMAT = {
|
|
|
26
26
|
"mistral-nemo-2407": "mistral-nemo@2407",
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
def get_model_info(model: str) -> Tuple[str,str]:
|
|
29
|
+
def get_model_info(model: str) -> Tuple[str, str]:
|
|
30
30
|
# if the model requiers the legacy fomat, use it, else do nothing.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if model in LEGACY_MODEL_ID_FORMAT:
|
|
32
|
+
return "-".join(model.split("-")[:-1]), LEGACY_MODEL_ID_FORMAT[model]
|
|
33
|
+
else:
|
|
34
|
+
return model, model
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
|
|
@@ -29,8 +29,8 @@ class SDKConfiguration:
|
|
|
29
29
|
language: str = "python"
|
|
30
30
|
openapi_doc_version: str = "0.0.2"
|
|
31
31
|
sdk_version: str = "1.2.3"
|
|
32
|
-
gen_version: str = "2.
|
|
33
|
-
user_agent: str = "speakeasy-sdk/python 1.2.3 2.
|
|
32
|
+
gen_version: str = "2.470.1"
|
|
33
|
+
user_agent: str = "speakeasy-sdk/python 1.2.3 2.470.1 0.0.2 mistralai-gcp"
|
|
34
34
|
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
|
|
35
35
|
timeout_ms: Optional[int] = None
|
|
36
36
|
|
|
@@ -1,30 +1,55 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from enum import Enum
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any, Optional
|
|
5
5
|
|
|
6
6
|
def get_discriminator(model: Any, fieldname: str, key: str) -> str:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return f'{model.get(key)}'
|
|
10
|
-
except AttributeError as e:
|
|
11
|
-
raise ValueError(f'Could not find discriminator key {key} in {model}') from e
|
|
7
|
+
"""
|
|
8
|
+
Recursively search for the discriminator attribute in a model.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
Args:
|
|
11
|
+
model (Any): The model to search within.
|
|
12
|
+
fieldname (str): The name of the field to search for.
|
|
13
|
+
key (str): The key to search for in dictionaries.
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Returns:
|
|
16
|
+
str: The name of the discriminator attribute.
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
Raises:
|
|
19
|
+
ValueError: If the discriminator attribute is not found.
|
|
20
|
+
"""
|
|
21
|
+
upper_fieldname = fieldname.upper()
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
attr = getattr(model, fieldname)
|
|
23
|
+
def get_field_discriminator(field: Any) -> Optional[str]:
|
|
24
|
+
"""Search for the discriminator attribute in a given field."""
|
|
24
25
|
|
|
25
|
-
if isinstance(
|
|
26
|
-
|
|
26
|
+
if isinstance(field, dict):
|
|
27
|
+
if key in field:
|
|
28
|
+
return f'{field[key]}'
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
if hasattr(field, fieldname):
|
|
31
|
+
attr = getattr(field, fieldname)
|
|
32
|
+
if isinstance(attr, Enum):
|
|
33
|
+
return f'{attr.value}'
|
|
34
|
+
return f'{attr}'
|
|
35
|
+
|
|
36
|
+
if hasattr(field, upper_fieldname):
|
|
37
|
+
attr = getattr(field, upper_fieldname)
|
|
38
|
+
if isinstance(attr, Enum):
|
|
39
|
+
return f'{attr.value}'
|
|
40
|
+
return f'{attr}'
|
|
41
|
+
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if isinstance(model, list):
|
|
46
|
+
for field in model:
|
|
47
|
+
discriminator = get_field_discriminator(field)
|
|
48
|
+
if discriminator is not None:
|
|
49
|
+
return discriminator
|
|
50
|
+
|
|
51
|
+
discriminator = get_field_discriminator(model)
|
|
52
|
+
if discriminator is not None:
|
|
53
|
+
return discriminator
|
|
29
54
|
|
|
30
55
|
raise ValueError(f'Could not find discriminator field {fieldname} in {model}')
|
|
@@ -2,12 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
4
|
import json
|
|
5
|
-
from typing import
|
|
5
|
+
from typing import (
|
|
6
|
+
Callable,
|
|
7
|
+
Generic,
|
|
8
|
+
TypeVar,
|
|
9
|
+
Optional,
|
|
10
|
+
Generator,
|
|
11
|
+
AsyncGenerator,
|
|
12
|
+
Tuple,
|
|
13
|
+
)
|
|
6
14
|
import httpx
|
|
7
15
|
|
|
8
16
|
T = TypeVar("T")
|
|
9
17
|
|
|
10
18
|
|
|
19
|
+
class EventStream(Generic[T]):
|
|
20
|
+
response: httpx.Response
|
|
21
|
+
generator: Generator[T, None, None]
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
response: httpx.Response,
|
|
26
|
+
decoder: Callable[[str], T],
|
|
27
|
+
sentinel: Optional[str] = None,
|
|
28
|
+
):
|
|
29
|
+
self.response = response
|
|
30
|
+
self.generator = stream_events(response, decoder, sentinel)
|
|
31
|
+
|
|
32
|
+
def __iter__(self):
|
|
33
|
+
return self
|
|
34
|
+
|
|
35
|
+
def __next__(self):
|
|
36
|
+
return next(self.generator)
|
|
37
|
+
|
|
38
|
+
def __enter__(self):
|
|
39
|
+
return self
|
|
40
|
+
|
|
41
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
42
|
+
self.response.close()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class EventStreamAsync(Generic[T]):
|
|
46
|
+
response: httpx.Response
|
|
47
|
+
generator: AsyncGenerator[T, None]
|
|
48
|
+
|
|
49
|
+
def __init__(
|
|
50
|
+
self,
|
|
51
|
+
response: httpx.Response,
|
|
52
|
+
decoder: Callable[[str], T],
|
|
53
|
+
sentinel: Optional[str] = None,
|
|
54
|
+
):
|
|
55
|
+
self.response = response
|
|
56
|
+
self.generator = stream_events_async(response, decoder, sentinel)
|
|
57
|
+
|
|
58
|
+
def __aiter__(self):
|
|
59
|
+
return self
|
|
60
|
+
|
|
61
|
+
async def __anext__(self):
|
|
62
|
+
return await self.generator.__anext__()
|
|
63
|
+
|
|
64
|
+
async def __aenter__(self):
|
|
65
|
+
return self
|
|
66
|
+
|
|
67
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
68
|
+
await self.response.aclose()
|
|
69
|
+
|
|
70
|
+
|
|
11
71
|
class ServerEvent:
|
|
12
72
|
id: Optional[str] = None
|
|
13
73
|
event: Optional[str] = None
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
FineTuneableModel = Literal[
|
|
8
|
-
"open-mistral-7b",
|
|
9
|
-
"mistral-small-latest",
|
|
10
|
-
"codestral-latest",
|
|
11
|
-
"mistral-large-latest",
|
|
12
|
-
"open-mistral-nemo",
|
|
13
|
-
]
|
|
14
|
-
r"""The name of the model to fine-tune."""
|
|
File without changes
|
|
File without changes
|