maitai-python 1.1.26b0__tar.gz → 1.1.28__tar.gz
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_python-1.1.26b0 → maitai_python-1.1.28}/PKG-INFO +1 -1
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_maitai.py +16 -4
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_maitai_async.py +16 -4
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/version.py +1 -1
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/chat/__init__.py +4 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/README.md +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_azure.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_config.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_config_listener_thread.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_context.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_evaluator.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_inference.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_maitai_client.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_types.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/_utils.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai/tools/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/utils/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/utils/proto_utils.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/utils/types.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/annotation/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/application/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/backtest/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/billing/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/company/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/config/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/embedding/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/event/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/inference/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/key/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/metric/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/model/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/notification/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/rates/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/sandbox/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/sentinel/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_gen/session/__init__.py +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_python.egg-info/SOURCES.txt +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/setup.cfg +0 -0
- {maitai_python-1.1.26b0 → maitai_python-1.1.28}/setup.py +0 -0
|
@@ -8,7 +8,6 @@ import httpx
|
|
|
8
8
|
import openai
|
|
9
9
|
import openai.types as openai_types
|
|
10
10
|
import openai.types.chat as openai_chat_types
|
|
11
|
-
from openai.types.chat import ChatCompletionStreamOptionsParam
|
|
12
11
|
|
|
13
12
|
import maitai
|
|
14
13
|
from maitai._config import config
|
|
@@ -266,8 +265,6 @@ class Completions:
|
|
|
266
265
|
presence_penalty = maitai_config.presence_penalty
|
|
267
266
|
if timeout == openai.NOT_GIVEN and maitai_config.timeout > 0:
|
|
268
267
|
timeout = maitai_config.timeout
|
|
269
|
-
if stream_options == openai.NOT_GIVEN and stream:
|
|
270
|
-
stream_options = ChatCompletionStreamOptionsParam(include_usage=True)
|
|
271
268
|
if context_retrieval_enabled is None:
|
|
272
269
|
context_retrieval_enabled = maitai_config.context_retrieval_enabled
|
|
273
270
|
if fallback_model is None and maitai_config.fallback_model:
|
|
@@ -331,7 +328,15 @@ class Completions:
|
|
|
331
328
|
retry_args["model"] = model
|
|
332
329
|
retry_args["fallback_model"] = fallback_model
|
|
333
330
|
return _process_inference_stream(
|
|
334
|
-
response,
|
|
331
|
+
response,
|
|
332
|
+
retry_args,
|
|
333
|
+
self.create,
|
|
334
|
+
timing,
|
|
335
|
+
includes_usage=(
|
|
336
|
+
stream_options.get("include_usage", False)
|
|
337
|
+
if stream_options and stream_options != openai.NOT_GIVEN
|
|
338
|
+
else False
|
|
339
|
+
),
|
|
335
340
|
)
|
|
336
341
|
# ChatCompletion only
|
|
337
342
|
for resp in response:
|
|
@@ -506,6 +511,7 @@ def _process_inference_stream(
|
|
|
506
511
|
retry_args: dict,
|
|
507
512
|
retry_func,
|
|
508
513
|
timing: RequestTimingMetric,
|
|
514
|
+
includes_usage: bool = False,
|
|
509
515
|
) -> Iterable[MaitaiChunk]:
|
|
510
516
|
first = True
|
|
511
517
|
try:
|
|
@@ -526,6 +532,12 @@ def _process_inference_stream(
|
|
|
526
532
|
maitai.Inference.store_request_timing_data(timing)
|
|
527
533
|
if chunk.usage:
|
|
528
534
|
return
|
|
535
|
+
if (
|
|
536
|
+
not includes_usage
|
|
537
|
+
and chunk.choices
|
|
538
|
+
and chunk.choices[0].finish_reason
|
|
539
|
+
):
|
|
540
|
+
return
|
|
529
541
|
except MaitaiConnectionError as e:
|
|
530
542
|
if "gpt" not in retry_args.get("model", "") and "gpt" in retry_args.get(
|
|
531
543
|
"fallback_model", ""
|
|
@@ -8,7 +8,6 @@ import httpx
|
|
|
8
8
|
import openai
|
|
9
9
|
import openai.types as openai_types
|
|
10
10
|
import openai.types.chat as openai_chat_types
|
|
11
|
-
from openai.types.chat import ChatCompletionStreamOptionsParam
|
|
12
11
|
|
|
13
12
|
import maitai
|
|
14
13
|
from maitai._config import config
|
|
@@ -264,8 +263,6 @@ class AsyncCompletions:
|
|
|
264
263
|
presence_penalty = maitai_config.presence_penalty
|
|
265
264
|
if timeout == openai.NOT_GIVEN and maitai_config.timeout > 0:
|
|
266
265
|
timeout = maitai_config.timeout
|
|
267
|
-
if stream_options == openai.NOT_GIVEN and stream:
|
|
268
|
-
stream_options = ChatCompletionStreamOptionsParam(include_usage=True)
|
|
269
266
|
if context_retrieval_enabled is None:
|
|
270
267
|
context_retrieval_enabled = maitai_config.context_retrieval_enabled
|
|
271
268
|
if fallback_model is None and maitai_config.fallback_model:
|
|
@@ -328,7 +325,15 @@ class AsyncCompletions:
|
|
|
328
325
|
retry_args["model"] = model
|
|
329
326
|
retry_args["fallback_model"] = fallback_model
|
|
330
327
|
return _process_inference_stream_async(
|
|
331
|
-
response,
|
|
328
|
+
response,
|
|
329
|
+
retry_args,
|
|
330
|
+
self.create,
|
|
331
|
+
timing,
|
|
332
|
+
includes_usage=(
|
|
333
|
+
stream_options.get("include_usage", False)
|
|
334
|
+
if stream_options and stream_options != openai.NOT_GIVEN
|
|
335
|
+
else False
|
|
336
|
+
),
|
|
332
337
|
)
|
|
333
338
|
# ChatCompletion only
|
|
334
339
|
async for resp in response:
|
|
@@ -505,6 +510,7 @@ async def _process_inference_stream_async(
|
|
|
505
510
|
retry_args: dict,
|
|
506
511
|
retry_func,
|
|
507
512
|
timing: RequestTimingMetric,
|
|
513
|
+
includes_usage: bool = False,
|
|
508
514
|
) -> AsyncIterable[MaitaiChunk]:
|
|
509
515
|
first = True
|
|
510
516
|
try:
|
|
@@ -525,6 +531,12 @@ async def _process_inference_stream_async(
|
|
|
525
531
|
maitai.Inference.store_request_timing_data(timing)
|
|
526
532
|
if chunk.usage:
|
|
527
533
|
return
|
|
534
|
+
if (
|
|
535
|
+
not includes_usage
|
|
536
|
+
and chunk.choices
|
|
537
|
+
and chunk.choices[0].finish_reason
|
|
538
|
+
):
|
|
539
|
+
return
|
|
528
540
|
except MaitaiConnectionError as e:
|
|
529
541
|
if "gpt" not in retry_args.get("model", "") and "gpt" in retry_args.get(
|
|
530
542
|
"fallback_model", ""
|
|
@@ -395,6 +395,10 @@ class Turn(betterproto.Message):
|
|
|
395
395
|
response: "ChatCompletionResponse" = betterproto.message_field(2)
|
|
396
396
|
eval_request: "EvaluateRequest" = betterproto.message_field(3)
|
|
397
397
|
application: "_application__.Application" = betterproto.message_field(4)
|
|
398
|
+
first: bool = betterproto.bool_field(5)
|
|
399
|
+
"""TODO: add EvaluateResponse"""
|
|
400
|
+
|
|
401
|
+
last: bool = betterproto.bool_field(6)
|
|
398
402
|
|
|
399
403
|
|
|
400
404
|
@dataclass(eq=False, repr=False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{maitai_python-1.1.26b0 → maitai_python-1.1.28}/maitai_common/processes/websocket_listener_thread.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|