maitai-python 1.1.5__tar.gz → 1.1.6__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.5 → maitai_python-1.1.6}/PKG-INFO +1 -1
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_config.py +2 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_types.py +2 -10
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/tools/__init__.py +2 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/version.py +1 -1
- maitai_python-1.1.6/maitai_gen/backtest/__init__.py +16 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/chat/__init__.py +33 -34
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_python.egg-info/SOURCES.txt +1 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/README.md +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_azure.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_config_listener_thread.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_context.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_evaluator.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_inference.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_maitai.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_maitai_async.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_maitai_client.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai/_utils.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/utils/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/utils/proto_utils.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_common/utils/types.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/application/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/company/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/config/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/embedding/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/event/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/inference/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/key/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/metric/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/model/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/notification/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/sandbox/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/sentinel/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_gen/session/__init__.py +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/setup.cfg +0 -0
- {maitai_python-1.1.5 → maitai_python-1.1.6}/setup.py +0 -0
|
@@ -82,6 +82,7 @@ class Config:
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
response = self._session.get(url, headers=headers, timeout=15)
|
|
85
|
+
self._session.close()
|
|
85
86
|
if response.status_code != 200:
|
|
86
87
|
print(f"Failed to initialize API client. Status code: {response.status_code}. Error: {response.text}")
|
|
87
88
|
return
|
|
@@ -98,6 +99,7 @@ class Config:
|
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
response = self._session.get(url, headers=headers, timeout=15)
|
|
102
|
+
self._session.close()
|
|
101
103
|
if response.status_code != 200:
|
|
102
104
|
print(f"Failed to initialize API client. Status code: {response.status_code}. Error: {response.text}")
|
|
103
105
|
return
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from datetime import datetime
|
|
3
2
|
from typing import Any, Mapping, Protocol, Union
|
|
4
3
|
|
|
5
4
|
import openai.types.chat as openai_chat_types
|
|
@@ -32,18 +31,12 @@ class MaitaiChunk(ChatCompletionChunk):
|
|
|
32
31
|
|
|
33
32
|
def openai_dump_json(self):
|
|
34
33
|
data = self.to_pydict(casing=Casing.SNAKE)
|
|
34
|
+
# 0 indices and empty arrays get removed by the omit default functions
|
|
35
35
|
if not data.get("choices"):
|
|
36
36
|
data["choices"] = []
|
|
37
|
-
if not data.get("created"):
|
|
38
|
-
data["created"] = int(datetime.utcnow().timestamp())
|
|
39
37
|
for i, choice in enumerate(data.get("choices")):
|
|
40
|
-
if choice.get("finish_reason") == "end_turn":
|
|
41
|
-
choice["finish_reason"] = "stop"
|
|
42
38
|
if not choice.get("index"):
|
|
43
39
|
choice["index"] = i
|
|
44
|
-
if not choice.get("delta"):
|
|
45
|
-
choice["delta"] = {
|
|
46
|
-
}
|
|
47
40
|
if choice["delta"].get("tool_calls"):
|
|
48
41
|
for j, tool_call in enumerate(choice["delta"]["tool_calls"]):
|
|
49
42
|
if not tool_call.get("index"):
|
|
@@ -71,11 +64,10 @@ class MaitaiCompletion(ChatCompletionResponse):
|
|
|
71
64
|
|
|
72
65
|
def openai_dump_json(self):
|
|
73
66
|
data = self.to_pydict(casing=Casing.SNAKE)
|
|
67
|
+
# 0 indices and empty arrays get removed by the omit default functions
|
|
74
68
|
for i, choice in enumerate(data.get("choices")):
|
|
75
69
|
if not choice.get("index"):
|
|
76
70
|
choice["index"] = i
|
|
77
|
-
if choice.get("finish_reason") == "end_turn":
|
|
78
|
-
choice["finish_reason"] = "stop"
|
|
79
71
|
if choice.get("message", {}).get("tool_calls"):
|
|
80
72
|
for j, tool_call in enumerate(choice["message"]["tool_calls"]):
|
|
81
73
|
if not tool_call.get("index"):
|
|
@@ -48,6 +48,8 @@ def tool(func):
|
|
|
48
48
|
|
|
49
49
|
param_descriptions = _extract_param_details(func.__doc__)
|
|
50
50
|
for param_name, param in params.items():
|
|
51
|
+
if param_name in ["self", "cls"]:
|
|
52
|
+
continue
|
|
51
53
|
if param_name in type_hints:
|
|
52
54
|
param_type = type_hints[param_name].__name__
|
|
53
55
|
elif param.default is not param.empty and param.default is not None:
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# sources: backtest.proto
|
|
3
|
+
# plugin: python-betterproto
|
|
4
|
+
# This file has been @generated
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import List
|
|
8
|
+
|
|
9
|
+
import betterproto
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(eq=False, repr=False)
|
|
13
|
+
class BacktestEvalTrigger(betterproto.Message):
|
|
14
|
+
company_id: int = betterproto.int64_field(1)
|
|
15
|
+
application_id: int = betterproto.int64_field(2)
|
|
16
|
+
session_ids: List[str] = betterproto.string_field(3)
|
|
@@ -41,11 +41,6 @@ class EvaluationContentType(betterproto.Enum):
|
|
|
41
41
|
PARTIAL = 2
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
class PromptStatus(betterproto.Enum):
|
|
45
|
-
BENIGN = 0
|
|
46
|
-
MALICIOUS = 1
|
|
47
|
-
|
|
48
|
-
|
|
49
44
|
@dataclass(eq=False, repr=False)
|
|
50
45
|
class ChatCompletionRequest(betterproto.Message):
|
|
51
46
|
params: "ChatCompletionParams" = betterproto.message_field(1)
|
|
@@ -364,19 +359,6 @@ class Turn(betterproto.Message):
|
|
|
364
359
|
eval_request: "EvaluateRequest" = betterproto.message_field(3)
|
|
365
360
|
|
|
366
361
|
|
|
367
|
-
@dataclass(eq=False, repr=False)
|
|
368
|
-
class PromptguardRequest(betterproto.Message):
|
|
369
|
-
company_id: int = betterproto.int64_field(1)
|
|
370
|
-
request_id: str = betterproto.string_field(2)
|
|
371
|
-
messages: List["ChatMessage"] = betterproto.message_field(3)
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
@dataclass(eq=False, repr=False)
|
|
375
|
-
class PromptguardResponse(betterproto.Message):
|
|
376
|
-
input_safety_score: float = betterproto.float_field(1)
|
|
377
|
-
status: "PromptStatus" = betterproto.enum_field(2)
|
|
378
|
-
|
|
379
|
-
|
|
380
362
|
@dataclass(eq=False, repr=False)
|
|
381
363
|
class SessionMessage(betterproto.Message):
|
|
382
364
|
id: int = betterproto.int64_field(1)
|
|
@@ -390,6 +372,23 @@ class SessionMessage(betterproto.Message):
|
|
|
390
372
|
date_created: int = betterproto.int64_field(9)
|
|
391
373
|
|
|
392
374
|
|
|
375
|
+
@dataclass(eq=False, repr=False)
|
|
376
|
+
class BacktestEvaluateRequest(betterproto.Message):
|
|
377
|
+
id: int = betterproto.int64_field(1)
|
|
378
|
+
date_created: int = betterproto.int64_field(2)
|
|
379
|
+
run_id: int = betterproto.int64_field(3)
|
|
380
|
+
company_id: int = betterproto.int64_field(4)
|
|
381
|
+
application_id: int = betterproto.int64_field(5)
|
|
382
|
+
backtest_application_id: int = betterproto.int64_field(6)
|
|
383
|
+
session_id: str = betterproto.string_field(7)
|
|
384
|
+
request_id: str = betterproto.string_field(8)
|
|
385
|
+
inference_request_id: str = betterproto.string_field(9)
|
|
386
|
+
action_type: str = betterproto.string_field(10)
|
|
387
|
+
request_messages: List["ChatMessage"] = betterproto.message_field(11)
|
|
388
|
+
response_message: "ChatCompletionMessage" = betterproto.message_field(12)
|
|
389
|
+
sentinels: List["_sentinel__.Sentinel"] = betterproto.message_field(13)
|
|
390
|
+
|
|
391
|
+
|
|
393
392
|
class EvaluationServiceStub(betterproto.ServiceStub):
|
|
394
393
|
async def evaluate(
|
|
395
394
|
self,
|
|
@@ -443,18 +442,18 @@ class EvaluationServiceStub(betterproto.ServiceStub):
|
|
|
443
442
|
metadata=metadata,
|
|
444
443
|
)
|
|
445
444
|
|
|
446
|
-
async def
|
|
445
|
+
async def backtest(
|
|
447
446
|
self,
|
|
448
|
-
|
|
447
|
+
backtest_evaluate_request: "BacktestEvaluateRequest",
|
|
449
448
|
*,
|
|
450
449
|
timeout: Optional[float] = None,
|
|
451
450
|
deadline: Optional["Deadline"] = None,
|
|
452
451
|
metadata: Optional["MetadataLike"] = None
|
|
453
|
-
) -> "
|
|
452
|
+
) -> "EvaluateResponse":
|
|
454
453
|
return await self._unary_unary(
|
|
455
|
-
"/chat.EvaluationService/
|
|
456
|
-
|
|
457
|
-
|
|
454
|
+
"/chat.EvaluationService/Backtest",
|
|
455
|
+
backtest_evaluate_request,
|
|
456
|
+
EvaluateResponse,
|
|
458
457
|
timeout=timeout,
|
|
459
458
|
deadline=deadline,
|
|
460
459
|
metadata=metadata,
|
|
@@ -477,9 +476,9 @@ class EvaluationServiceBase(ServiceBase):
|
|
|
477
476
|
) -> "betterproto_lib_google_protobuf.Empty":
|
|
478
477
|
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
479
478
|
|
|
480
|
-
async def
|
|
481
|
-
self,
|
|
482
|
-
) -> "
|
|
479
|
+
async def backtest(
|
|
480
|
+
self, backtest_evaluate_request: "BacktestEvaluateRequest"
|
|
481
|
+
) -> "EvaluateResponse":
|
|
483
482
|
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
484
483
|
|
|
485
484
|
async def __rpc_evaluate(
|
|
@@ -507,11 +506,11 @@ class EvaluationServiceBase(ServiceBase):
|
|
|
507
506
|
response = await self.evaluate_async(request)
|
|
508
507
|
await stream.send_message(response)
|
|
509
508
|
|
|
510
|
-
async def
|
|
511
|
-
self, stream: "grpclib.server.Stream[
|
|
509
|
+
async def __rpc_backtest(
|
|
510
|
+
self, stream: "grpclib.server.Stream[BacktestEvaluateRequest, EvaluateResponse]"
|
|
512
511
|
) -> None:
|
|
513
512
|
request = await stream.recv_message()
|
|
514
|
-
response = await self.
|
|
513
|
+
response = await self.backtest(request)
|
|
515
514
|
await stream.send_message(response)
|
|
516
515
|
|
|
517
516
|
def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
|
|
@@ -534,10 +533,10 @@ class EvaluationServiceBase(ServiceBase):
|
|
|
534
533
|
EvaluateRequest,
|
|
535
534
|
betterproto_lib_google_protobuf.Empty,
|
|
536
535
|
),
|
|
537
|
-
"/chat.EvaluationService/
|
|
538
|
-
self.
|
|
536
|
+
"/chat.EvaluationService/Backtest": grpclib.const.Handler(
|
|
537
|
+
self.__rpc_backtest,
|
|
539
538
|
grpclib.const.Cardinality.UNARY_UNARY,
|
|
540
|
-
|
|
541
|
-
|
|
539
|
+
BacktestEvaluateRequest,
|
|
540
|
+
EvaluateResponse,
|
|
542
541
|
),
|
|
543
542
|
}
|
|
@@ -25,6 +25,7 @@ maitai_common/utils/proto_utils.py
|
|
|
25
25
|
maitai_common/utils/types.py
|
|
26
26
|
maitai_gen/__init__.py
|
|
27
27
|
maitai_gen/application/__init__.py
|
|
28
|
+
maitai_gen/backtest/__init__.py
|
|
28
29
|
maitai_gen/chat/__init__.py
|
|
29
30
|
maitai_gen/company/__init__.py
|
|
30
31
|
maitai_gen/config/__init__.py
|
|
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.5 → maitai_python-1.1.6}/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
|