mistralai 0.1.8__py3-none-any.whl → 0.2.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/async_client.py +3 -4
- mistralai/client.py +1 -2
- mistralai/client_base.py +7 -7
- mistralai/constants.py +0 -2
- mistralai/exceptions.py +3 -3
- mistralai/models/chat_completion.py +1 -0
- mistralai/models/models.py +1 -0
- {mistralai-0.1.8.dist-info → mistralai-0.2.0.dist-info}/METADATA +2 -2
- mistralai-0.2.0.dist-info/RECORD +16 -0
- mistralai-0.1.8.dist-info/RECORD +0 -16
- {mistralai-0.1.8.dist-info → mistralai-0.2.0.dist-info}/LICENSE +0 -0
- {mistralai-0.1.8.dist-info → mistralai-0.2.0.dist-info}/WHEEL +0 -0
mistralai/async_client.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import asyncio
|
|
2
2
|
import posixpath
|
|
3
|
-
import time
|
|
4
3
|
from json import JSONDecodeError
|
|
5
4
|
from typing import Any, AsyncGenerator, Dict, List, Optional, Union
|
|
6
5
|
|
|
@@ -34,7 +33,7 @@ from mistralai.models.models import ModelList
|
|
|
34
33
|
class MistralAsyncClient(ClientBase):
|
|
35
34
|
def __init__(
|
|
36
35
|
self,
|
|
37
|
-
api_key: Optional[str] =
|
|
36
|
+
api_key: Optional[str] = None,
|
|
38
37
|
endpoint: str = ENDPOINT,
|
|
39
38
|
max_retries: int = 5,
|
|
40
39
|
timeout: int = 120,
|
|
@@ -151,7 +150,7 @@ class MistralAsyncClient(ClientBase):
|
|
|
151
150
|
if attempt > self._max_retries:
|
|
152
151
|
raise MistralAPIStatusException.from_response(response, message=str(e)) from e
|
|
153
152
|
backoff = 2.0**attempt # exponential backoff
|
|
154
|
-
|
|
153
|
+
await asyncio.sleep(backoff)
|
|
155
154
|
|
|
156
155
|
# Retry as a generator
|
|
157
156
|
async for r in self._request(method, json, path, stream=stream, attempt=attempt):
|
mistralai/client.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import posixpath
|
|
3
2
|
import time
|
|
4
3
|
from json import JSONDecodeError
|
|
@@ -31,7 +30,7 @@ class MistralClient(ClientBase):
|
|
|
31
30
|
|
|
32
31
|
def __init__(
|
|
33
32
|
self,
|
|
34
|
-
api_key: Optional[str] =
|
|
33
|
+
api_key: Optional[str] = None,
|
|
35
34
|
endpoint: str = ENDPOINT,
|
|
36
35
|
max_retries: int = 5,
|
|
37
36
|
timeout: int = 120,
|
mistralai/client_base.py
CHANGED
|
@@ -10,10 +10,7 @@ from mistralai.exceptions import (
|
|
|
10
10
|
)
|
|
11
11
|
from mistralai.models.chat_completion import ChatMessage, Function, ResponseFormat, ToolChoice
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
15
|
-
level=os.getenv("LOG_LEVEL", "ERROR"),
|
|
16
|
-
)
|
|
13
|
+
CLIENT_VERSION = "0.2.0"
|
|
17
14
|
|
|
18
15
|
|
|
19
16
|
class ClientBase(ABC):
|
|
@@ -27,16 +24,19 @@ class ClientBase(ABC):
|
|
|
27
24
|
self._max_retries = max_retries
|
|
28
25
|
self._timeout = timeout
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
if api_key is None:
|
|
28
|
+
api_key = os.environ.get("MISTRAL_API_KEY")
|
|
29
|
+
if api_key is None:
|
|
30
|
+
raise MistralException(message="API key not provided. Please set MISTRAL_API_KEY environment variable.")
|
|
31
31
|
self._api_key = api_key
|
|
32
|
+
self._endpoint = endpoint
|
|
32
33
|
self._logger = logging.getLogger(__name__)
|
|
33
34
|
|
|
34
35
|
# For azure endpoints, we default to the mistral model
|
|
35
36
|
if "inference.azure.com" in self._endpoint:
|
|
36
37
|
self._default_model = "mistral"
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
self._version = "0.1.8"
|
|
39
|
+
self._version = CLIENT_VERSION
|
|
40
40
|
|
|
41
41
|
def _parse_tools(self, tools: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
|
42
42
|
parsed_tools: List[Dict[str, Any]] = []
|
mistralai/constants.py
CHANGED
mistralai/exceptions.py
CHANGED
|
@@ -35,9 +35,7 @@ class MistralAPIException(MistralException):
|
|
|
35
35
|
self.headers = headers or {}
|
|
36
36
|
|
|
37
37
|
@classmethod
|
|
38
|
-
def from_response(
|
|
39
|
-
cls, response: Response, message: Optional[str] = None
|
|
40
|
-
) -> MistralAPIException:
|
|
38
|
+
def from_response(cls, response: Response, message: Optional[str] = None) -> MistralAPIException:
|
|
41
39
|
return cls(
|
|
42
40
|
message=message or response.text,
|
|
43
41
|
http_status=response.status_code,
|
|
@@ -47,8 +45,10 @@ class MistralAPIException(MistralException):
|
|
|
47
45
|
def __repr__(self) -> str:
|
|
48
46
|
return f"{self.__class__.__name__}(message={str(self)}, http_status={self.http_status})"
|
|
49
47
|
|
|
48
|
+
|
|
50
49
|
class MistralAPIStatusException(MistralAPIException):
|
|
51
50
|
"""Returned when we receive a non-200 response from the API that we should retry"""
|
|
52
51
|
|
|
52
|
+
|
|
53
53
|
class MistralConnectionException(MistralException):
|
|
54
54
|
"""Returned when the SDK can not reach the API server for any reason"""
|
mistralai/models/models.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mistralai
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary:
|
|
5
5
|
Author: Bam4d
|
|
6
6
|
Author-email: bam4d@mistral.ai
|
|
@@ -10,7 +10,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Requires-Dist: httpx (>=0.25.2,<
|
|
13
|
+
Requires-Dist: httpx (>=0.25.2,<1)
|
|
14
14
|
Requires-Dist: orjson (>=3.9.10,<4.0.0)
|
|
15
15
|
Requires-Dist: pydantic (>=2.5.2,<3.0.0)
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
mistralai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mistralai/async_client.py,sha256=orHDWXtchV8yYk5AQdX-rBPvPdARFdAXqjX_Mlo6H8U,11378
|
|
3
|
+
mistralai/client.py,sha256=3ta6VFeKKngp1tI8doK7WKDLcndk_4LYAbn01_6GodE,11119
|
|
4
|
+
mistralai/client_base.py,sha256=SY8E1VctuPvD3LVTX0hudUGRHd-j6xee-LtE0f2ABSs,4710
|
|
5
|
+
mistralai/constants.py,sha256=FvokZPfTBC-DC6-HfiV83pD3FP6huHk3SUIl0yx5jx8,84
|
|
6
|
+
mistralai/exceptions.py,sha256=R3pswvZyY5CuSbqhVklgfGPVJoz7T7l2VQKMOXK229A,1652
|
|
7
|
+
mistralai/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
mistralai/models/chat_completion.py,sha256=E751VZ_YXm5xNuwLiGdb8RThJ7OC19S25AHMm0Sf1ng,1884
|
|
9
|
+
mistralai/models/common.py,sha256=zatP4aV_LIEpzj3_igsKkJBICwGhmXG0LX3CdO3kn-o,172
|
|
10
|
+
mistralai/models/embeddings.py,sha256=-VthLQBj6wrq7HXJbGmnkQEEanSemA3MAlaMFh94VBg,331
|
|
11
|
+
mistralai/models/models.py,sha256=mDNIPnbsZOnfS7i8563NnIvYYxYbavu1CBijEoEqitw,714
|
|
12
|
+
mistralai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
mistralai-0.2.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
14
|
+
mistralai-0.2.0.dist-info/METADATA,sha256=r-IhqjSA1z1eQcN7uU2Nm0oCe5fAfJaagkH64-ZKHeQ,1831
|
|
15
|
+
mistralai-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
16
|
+
mistralai-0.2.0.dist-info/RECORD,,
|
mistralai-0.1.8.dist-info/RECORD
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
mistralai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
mistralai/async_client.py,sha256=dpaZ7W7R2Fmo19vvf1SfyViT6JbmjJUGzaT-keT1vTc,11411
|
|
3
|
-
mistralai/client.py,sha256=cneaYGtFOkrE0sUPh6GQeuX_eXKcCpNjomJjPlVWD4g,11164
|
|
4
|
-
mistralai/client_base.py,sha256=hujTJDw6huSpe21brkvw8o0k5Xr1CmEXA9D6qD0Susk,4645
|
|
5
|
-
mistralai/constants.py,sha256=KK286HFjpoTxPKih8xdTp0lW4YMDPyYu2Shi3Nu5Vdw,86
|
|
6
|
-
mistralai/exceptions.py,sha256=d1cli28ZaPEBQy2RKKcSh-dO2T20GXHNoaJrXXBmyIs,1664
|
|
7
|
-
mistralai/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
mistralai/models/chat_completion.py,sha256=WnjepDpenuzDjpzkCu3RPaR1snMead7krfM1OgLsVLs,1845
|
|
9
|
-
mistralai/models/common.py,sha256=zatP4aV_LIEpzj3_igsKkJBICwGhmXG0LX3CdO3kn-o,172
|
|
10
|
-
mistralai/models/embeddings.py,sha256=-VthLQBj6wrq7HXJbGmnkQEEanSemA3MAlaMFh94VBg,331
|
|
11
|
-
mistralai/models/models.py,sha256=I4I1kQwP0tJ2_rd4lbSUwOkCJE5E-dSTIExQg2ZNFcw,713
|
|
12
|
-
mistralai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
mistralai-0.1.8.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
14
|
-
mistralai-0.1.8.dist-info/METADATA,sha256=2oEOkdjck_AQmqnIkowiXOTovKcv0frrtLb5IhcENXU,1836
|
|
15
|
-
mistralai-0.1.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
16
|
-
mistralai-0.1.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|