maitai-python 1.2.1__py3-none-any.whl → 1.2.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.
- maitai/_maitai.py +22 -2
- maitai/_maitai_async.py +21 -2
- maitai/_types.py +7 -1
- maitai_common/version.py +1 -1
- maitai_gen/chat/__init__.py +2 -0
- maitai_gen/config/__init__.py +8 -0
- maitai_gen/model.py +3 -3
- {maitai_python-1.2.1.dist-info → maitai_python-1.2.2.dist-info}/METADATA +1 -1
- {maitai_python-1.2.1.dist-info → maitai_python-1.2.2.dist-info}/RECORD +11 -11
- {maitai_python-1.2.1.dist-info → maitai_python-1.2.2.dist-info}/WHEEL +0 -0
- {maitai_python-1.2.1.dist-info → maitai_python-1.2.2.dist-info}/top_level.txt +0 -0
maitai/_maitai.py
CHANGED
|
@@ -20,6 +20,7 @@ from maitai._inference import (
|
|
|
20
20
|
from maitai._types import (
|
|
21
21
|
Body,
|
|
22
22
|
EvaluateCallback,
|
|
23
|
+
FallbackConfig,
|
|
23
24
|
Headers,
|
|
24
25
|
MaitaiChunk,
|
|
25
26
|
MaitaiCompletion,
|
|
@@ -155,6 +156,7 @@ class Completions:
|
|
|
155
156
|
assistant: bool = False,
|
|
156
157
|
metadata: dict = {},
|
|
157
158
|
safe_mode: bool = None,
|
|
159
|
+
fallback_config: FallbackConfig = None,
|
|
158
160
|
# OpenAI Arguments
|
|
159
161
|
messages: Iterable[openai_chat_types.ChatCompletionMessageParam],
|
|
160
162
|
model: Union[str, openai_types.ChatModel, openai.NotGiven] = openai.NOT_GIVEN,
|
|
@@ -270,8 +272,25 @@ class Completions:
|
|
|
270
272
|
timeout = maitai_config.timeout
|
|
271
273
|
if context_retrieval_enabled is None:
|
|
272
274
|
context_retrieval_enabled = maitai_config.context_retrieval_enabled
|
|
273
|
-
if fallback_model
|
|
274
|
-
|
|
275
|
+
if fallback_model:
|
|
276
|
+
warnings.warn(
|
|
277
|
+
"fallback_model is deprecated. Use fallback_config instead.",
|
|
278
|
+
DeprecationWarning,
|
|
279
|
+
)
|
|
280
|
+
if fallback_config is None and maitai_config.fallback_config:
|
|
281
|
+
fallback_config = {
|
|
282
|
+
"model": maitai_config.fallback_config.model,
|
|
283
|
+
"strategy": maitai_config.fallback_config.strategy,
|
|
284
|
+
"timeout": maitai_config.fallback_config.timeout,
|
|
285
|
+
}
|
|
286
|
+
if fallback_config is None and fallback_model:
|
|
287
|
+
fallback_config = {
|
|
288
|
+
"model": fallback_model,
|
|
289
|
+
"strategy": "reactive",
|
|
290
|
+
"timeout": None,
|
|
291
|
+
}
|
|
292
|
+
if fallback_config and "model" in fallback_config:
|
|
293
|
+
fallback_model = fallback_config["model"]
|
|
275
294
|
completion_params = get_chat_completion_params(
|
|
276
295
|
messages=messages,
|
|
277
296
|
model=model,
|
|
@@ -317,6 +336,7 @@ class Completions:
|
|
|
317
336
|
"auth_keys": config.auth_keys.to_dict(),
|
|
318
337
|
"metadata": metadata,
|
|
319
338
|
"safe_mode": safe_mode,
|
|
339
|
+
"fallback_config": fallback_config,
|
|
320
340
|
}
|
|
321
341
|
|
|
322
342
|
if self._client_params is not None:
|
maitai/_maitai_async.py
CHANGED
|
@@ -20,6 +20,7 @@ from maitai._inference import (
|
|
|
20
20
|
from maitai._types import (
|
|
21
21
|
Body,
|
|
22
22
|
EvaluateCallback,
|
|
23
|
+
FallbackConfig,
|
|
23
24
|
Headers,
|
|
24
25
|
MaitaiChunk,
|
|
25
26
|
MaitaiCompletion,
|
|
@@ -156,6 +157,7 @@ class AsyncCompletions:
|
|
|
156
157
|
assistant: bool = False,
|
|
157
158
|
metadata: dict = {},
|
|
158
159
|
safe_mode: bool = None,
|
|
160
|
+
fallback_config: FallbackConfig = None,
|
|
159
161
|
# OpenAI Arguments
|
|
160
162
|
messages: Iterable[openai_chat_types.ChatCompletionMessageParam],
|
|
161
163
|
model: Union[str, openai_types.ChatModel, openai.NotGiven] = openai.NOT_GIVEN,
|
|
@@ -271,8 +273,25 @@ class AsyncCompletions:
|
|
|
271
273
|
timeout = maitai_config.timeout
|
|
272
274
|
if context_retrieval_enabled is None:
|
|
273
275
|
context_retrieval_enabled = maitai_config.context_retrieval_enabled
|
|
274
|
-
if fallback_model is None
|
|
275
|
-
|
|
276
|
+
if fallback_model is not None:
|
|
277
|
+
warnings.warn(
|
|
278
|
+
"fallback_model is deprecated. Use fallback_config instead.",
|
|
279
|
+
DeprecationWarning,
|
|
280
|
+
)
|
|
281
|
+
if fallback_config is None and maitai_config.fallback_config:
|
|
282
|
+
fallback_config = {
|
|
283
|
+
"model": maitai_config.fallback_config.model,
|
|
284
|
+
"strategy": maitai_config.fallback_config.strategy,
|
|
285
|
+
"timeout": maitai_config.fallback_config.timeout,
|
|
286
|
+
}
|
|
287
|
+
if fallback_config is None and fallback_model:
|
|
288
|
+
fallback_config = {
|
|
289
|
+
"model": fallback_model,
|
|
290
|
+
"strategy": "reactive",
|
|
291
|
+
"timeout": None,
|
|
292
|
+
}
|
|
293
|
+
if fallback_config and "model" in fallback_config:
|
|
294
|
+
fallback_model = fallback_config["model"]
|
|
276
295
|
completion_params = get_chat_completion_params(
|
|
277
296
|
messages=messages,
|
|
278
297
|
model=model,
|
maitai/_types.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
3
|
import queue
|
|
4
|
-
from typing import Any, Callable, Mapping, Optional, Protocol, Union
|
|
4
|
+
from typing import Any, Callable, Mapping, Optional, Protocol, TypedDict, Union
|
|
5
5
|
|
|
6
6
|
import openai.types.chat as openai_chat_types
|
|
7
7
|
from betterproto import Casing
|
|
@@ -185,3 +185,9 @@ class QueueIterable:
|
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
EvaluateCallback = Callable[[EvaluateResponse], None]
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class FallbackConfig(TypedDict):
|
|
191
|
+
model: Optional[str]
|
|
192
|
+
strategy: Literal["reactive", "first_response", "timeout"]
|
|
193
|
+
timeout: Optional[float]
|
maitai_common/version.py
CHANGED
maitai_gen/chat/__init__.py
CHANGED
|
@@ -18,6 +18,7 @@ from betterproto.grpc.grpclib_server import ServiceBase
|
|
|
18
18
|
|
|
19
19
|
from .. import (
|
|
20
20
|
application as _application__,
|
|
21
|
+
config as _config__,
|
|
21
22
|
key as _key__,
|
|
22
23
|
metric as _metric__,
|
|
23
24
|
sentinel as _sentinel__,
|
|
@@ -73,6 +74,7 @@ class ChatCompletionRequest(betterproto.Message):
|
|
|
73
74
|
25, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
|
74
75
|
)
|
|
75
76
|
safe_mode: bool = betterproto.bool_field(26)
|
|
77
|
+
fallback_config: "_config__.FallbackConfig" = betterproto.message_field(27)
|
|
76
78
|
|
|
77
79
|
|
|
78
80
|
@dataclass(eq=False, repr=False)
|
maitai_gen/config/__init__.py
CHANGED
|
@@ -17,6 +17,13 @@ class InferenceLocations(betterproto.Enum):
|
|
|
17
17
|
SERVER = 1
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
@dataclass(eq=False, repr=False)
|
|
21
|
+
class FallbackConfig(betterproto.Message):
|
|
22
|
+
model: str = betterproto.string_field(1)
|
|
23
|
+
strategy: str = betterproto.string_field(2)
|
|
24
|
+
timeout: float = betterproto.double_field(3)
|
|
25
|
+
|
|
26
|
+
|
|
20
27
|
@dataclass(eq=False, repr=False)
|
|
21
28
|
class Config(betterproto.Message):
|
|
22
29
|
inference_location: "InferenceLocations" = betterproto.enum_field(1)
|
|
@@ -40,6 +47,7 @@ class Config(betterproto.Message):
|
|
|
40
47
|
feedback: List[str] = betterproto.string_field(22)
|
|
41
48
|
generating_sentinels: bool = betterproto.bool_field(23)
|
|
42
49
|
sentinel_regeneration_enabled: bool = betterproto.bool_field(24)
|
|
50
|
+
fallback_config: "FallbackConfig" = betterproto.message_field(25)
|
|
43
51
|
|
|
44
52
|
|
|
45
53
|
@dataclass(eq=False, repr=False)
|
maitai_gen/model.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# This is an automatically generated file, please do not change
|
|
2
|
-
# gen by protobuf_to_pydantic[v0.3.0](https://github.com/so1n/protobuf_to_pydantic)
|
|
3
|
-
# Protobuf Version: 5.
|
|
4
|
-
# Pydantic Version: 2.
|
|
2
|
+
# gen by protobuf_to_pydantic[v0.3.0.3](https://github.com/so1n/protobuf_to_pydantic)
|
|
3
|
+
# Protobuf Version: 5.29.2
|
|
4
|
+
# Pydantic Version: 2.10.4
|
|
5
5
|
import typing
|
|
6
6
|
|
|
7
7
|
from google.protobuf.message import Message # type: ignore
|
|
@@ -5,27 +5,27 @@ maitai/_config_listener_thread.py,sha256=VaftjUXrP8oe6yg0TXUlIZW2vGw7bTk8p_95o4d
|
|
|
5
5
|
maitai/_context.py,sha256=WmCLGd7BK1ViImd7uDTsjly7ECcugioZhGjxXwETHfI,2401
|
|
6
6
|
maitai/_evaluator.py,sha256=qbwj--FCvNnRz-LTpuenMYf-2eGZRMrPqxepSerKWUo,10355
|
|
7
7
|
maitai/_inference.py,sha256=uINtF7KUFGfLDZ4wQ8rI45czfl7qYU4GcrGVv0nFaEc,13624
|
|
8
|
-
maitai/_maitai.py,sha256=
|
|
9
|
-
maitai/_maitai_async.py,sha256=
|
|
8
|
+
maitai/_maitai.py,sha256=KEMxf0nIPsV8ZEkZfNoNZ6Ae2CPT5iH10-9syXuwdOw,24404
|
|
9
|
+
maitai/_maitai_async.py,sha256=YfCo7G5trBNpEmLztDWs6Uk34O1b2nJsA4IkShuuazI,24504
|
|
10
10
|
maitai/_maitai_client.py,sha256=NrICbHWhfx-u6pdXSUCjKRlPYmJO9nWb4hgnr3vf1y8,1981
|
|
11
|
-
maitai/_types.py,sha256=
|
|
11
|
+
maitai/_types.py,sha256=uIYm1YQv6ZmGZ4GG6p6xrCjfVGq8VSxkehLgRqtr1Rw,6436
|
|
12
12
|
maitai/_utils.py,sha256=3JN5MClGZNkcmn-hWgi8fNV2n-Ytlek37H3S6TEHzuk,11276
|
|
13
13
|
maitai/tools/__init__.py,sha256=TxJ-g4A0eIzoIMD60ctIPVppCWcdcuZWms3hPGrqkSs,4043
|
|
14
14
|
maitai_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
maitai_common/version.py,sha256=
|
|
15
|
+
maitai_common/version.py,sha256=j2u0CvKX_frZofU-GGJNf9eBuHdU1JppJyw42qkAmUk,64
|
|
16
16
|
maitai_common/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
maitai_common/config/config_service.py,sha256=U8hU0F9juZtrZwIayOM_OBShxynUS8gu5K0F40KvcA0,940
|
|
18
18
|
maitai_common/processes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
maitai_common/processes/io_thread.py,sha256=Pqw-3Pz6rlJvK_6P5ytgGoXP7pymYQzuDhTGaeOSLW8,1995
|
|
20
20
|
maitai_common/processes/websocket_listener_thread.py,sha256=CaFtcHby8iEnjQNawGkvcKhr7S_pqvavW8gXw0YUjnM,3482
|
|
21
21
|
maitai_gen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
maitai_gen/model.py,sha256=
|
|
22
|
+
maitai_gen/model.py,sha256=EQoBLRHJ6TahP5vsHZCTFPUnzSHFlww_PkN0I7lEAh8,913
|
|
23
23
|
maitai_gen/application/__init__.py,sha256=PY7Q6Lxr7YfyhmFe_xnbGlz14tGoBEbpYA6EBEAI7M0,2430
|
|
24
24
|
maitai_gen/backtest/__init__.py,sha256=_9B-q5F1YTPOgGLBTRZCdFnv54SizjfK0bFCaDi6UzM,467
|
|
25
25
|
maitai_gen/billing/__init__.py,sha256=yP9k5pCuI8mehQDHqVrBDWldVsLZ7-LlwpRorESdsN4,2664
|
|
26
|
-
maitai_gen/chat/__init__.py,sha256=
|
|
26
|
+
maitai_gen/chat/__init__.py,sha256=DqsoSJE2wDMXVhTrKRip3j8hCAcde8uxJZOMsbkgYl0,22330
|
|
27
27
|
maitai_gen/company/__init__.py,sha256=Jj03m8QlVsGLr0VQA-T5yxjbC1R3cx0gthUwgtbtGuc,739
|
|
28
|
-
maitai_gen/config/__init__.py,sha256=
|
|
28
|
+
maitai_gen/config/__init__.py,sha256=k9tdqH1uhV-cYkZn1FtP4rzMxmKJRGJzxaToWFbTY1g,2298
|
|
29
29
|
maitai_gen/embedding/__init__.py,sha256=py5vAEdXFatL7daub1YSnruIRV-im0heWSa5hjaSljM,941
|
|
30
30
|
maitai_gen/evaluation/__init__.py,sha256=CjB_Vnokmfawg-wte9YLB-e4OR8A6QI1B1ftZc7Pe_A,1777
|
|
31
31
|
maitai_gen/event/__init__.py,sha256=puOhfH-KQu_fL-yPJPjceDhwy3VbzP0oTtQs-RHeTE4,670
|
|
@@ -38,7 +38,7 @@ maitai_gen/rates/__init__.py,sha256=Aho7HzMKRfjQz10tMJCoRVttq_cGlYh2DxxpSyTQAzU,
|
|
|
38
38
|
maitai_gen/sandbox/__init__.py,sha256=IZ4hf76V1aZrYk5S-4p7z38e-op_s341utVG2domE_g,1549
|
|
39
39
|
maitai_gen/sentinel/__init__.py,sha256=3yR28usTBIAC-M_uxEUFgqXo2PWylEKEPYmWX_dp7Cs,2513
|
|
40
40
|
maitai_gen/session/__init__.py,sha256=kCJweCFagUqGkzktucaWLti9HSLaO5AML8Jewl89yM0,1242
|
|
41
|
-
maitai_python-1.2.
|
|
42
|
-
maitai_python-1.2.
|
|
43
|
-
maitai_python-1.2.
|
|
44
|
-
maitai_python-1.2.
|
|
41
|
+
maitai_python-1.2.2.dist-info/METADATA,sha256=Nq7FNaAtVVP7C6O8tZDuyDIiYhfhF2Yarrh0NNrJykI,1494
|
|
42
|
+
maitai_python-1.2.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
43
|
+
maitai_python-1.2.2.dist-info/top_level.txt,sha256=-5U1krxnwlqB-AY7nEe29ZcNvwByNc-SnBe-mph-QjI,32
|
|
44
|
+
maitai_python-1.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|