maitai-python 1.1.4b0__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.4b0 → maitai_python-1.1.6}/PKG-INFO +1 -1
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_config.py +2 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_evaluator.py +5 -3
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_inference.py +4 -4
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_maitai.py +13 -3
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_maitai_async.py +11 -2
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_types.py +2 -10
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/tools/__init__.py +2 -0
- {maitai_python-1.1.4b0 → 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.4b0 → maitai_python-1.1.6}/maitai_gen/chat/__init__.py +36 -34
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_python.egg-info/SOURCES.txt +1 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/README.md +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_azure.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_config_listener_thread.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_context.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_maitai_client.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai/_utils.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/utils/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/utils/proto_utils.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_common/utils/types.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/application/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/company/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/config/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/embedding/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/event/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/inference/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/key/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/metric/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/model/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/notification/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/sandbox/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/sentinel/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_gen/session/__init__.py +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.1.4b0 → maitai_python-1.1.6}/setup.cfg +0 -0
- {maitai_python-1.1.4b0 → 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
|
|
@@ -11,6 +11,7 @@ from maitai._maitai_client import MaitaiClient
|
|
|
11
11
|
from maitai._utils import __version__ as version, chat_completion_chunk_to_response
|
|
12
12
|
from maitai_common.utils.types import EvaluateCallback
|
|
13
13
|
from maitai_gen.chat import ChatCompletionChunk, ChatCompletionParams, ChatCompletionResponse, EvaluateRequest, EvaluateResponse, EvaluationContentType
|
|
14
|
+
from maitai_gen.metric import RequestTimingMetric
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
def _get_content_type(content, partial=None):
|
|
@@ -29,7 +30,7 @@ class Evaluator(MaitaiClient):
|
|
|
29
30
|
|
|
30
31
|
@classmethod
|
|
31
32
|
async def evaluate_async(cls, session_id, reference_id, intent, content, content_type=None, application_id=None, application_ref_name=None, callback=None, completion_params: ChatCompletionParams = None,
|
|
32
|
-
chat_completion_response: ChatCompletionResponse = None, chat_completion_chunk: ChatCompletionChunk = None):
|
|
33
|
+
chat_completion_response: ChatCompletionResponse = None, chat_completion_chunk: ChatCompletionChunk = None, timing: RequestTimingMetric = None):
|
|
33
34
|
if content_type is None:
|
|
34
35
|
content_type = _get_content_type(content)
|
|
35
36
|
if content_type is None:
|
|
@@ -42,12 +43,12 @@ class Evaluator(MaitaiClient):
|
|
|
42
43
|
if chat_completion_chunk is not None:
|
|
43
44
|
chat_completion_response = chat_completion_chunk_to_response(chat_completion_chunk, content)
|
|
44
45
|
eval_request.chat_completion_response = chat_completion_response
|
|
45
|
-
|
|
46
|
+
eval_request.timing_metrics = timing
|
|
46
47
|
await asyncio.create_task(cls.send_evaluation_request_async(eval_request, callback))
|
|
47
48
|
|
|
48
49
|
@classmethod
|
|
49
50
|
def evaluate(cls, session_id, reference_id, intent, content, content_type=None, application_id=None, application_ref_name=None, callback=None, partial=None, completion_params: ChatCompletionParams = None,
|
|
50
|
-
chat_completion_response: ChatCompletionResponse = None, chat_completion_chunk: ChatCompletionChunk = None):
|
|
51
|
+
chat_completion_response: ChatCompletionResponse = None, chat_completion_chunk: ChatCompletionChunk = None, timing: RequestTimingMetric = None):
|
|
51
52
|
if content_type is None:
|
|
52
53
|
content_type = _get_content_type(content, partial)
|
|
53
54
|
if content_type is None:
|
|
@@ -60,6 +61,7 @@ class Evaluator(MaitaiClient):
|
|
|
60
61
|
if chat_completion_chunk is not None:
|
|
61
62
|
chat_completion_response = chat_completion_chunk_to_response(chat_completion_chunk, content)
|
|
62
63
|
eval_request.chat_completion_response = chat_completion_response
|
|
64
|
+
eval_request.timing_metrics = timing
|
|
63
65
|
|
|
64
66
|
cls.run_async(cls.send_evaluation_request_async(eval_request, callback))
|
|
65
67
|
|
|
@@ -51,17 +51,17 @@ class Inference(MaitaiClient):
|
|
|
51
51
|
|
|
52
52
|
@classmethod
|
|
53
53
|
def create_chat_storage_request(cls, session_id, reference_id, intent, application_ref_name, completion_params: ChatCompletionParams, chat_completion_response: Optional[ChatCompletionResponse],
|
|
54
|
-
final_chunk: Optional[ChatCompletionChunk], content: str):
|
|
54
|
+
final_chunk: Optional[ChatCompletionChunk], content: str, timing: RequestTimingMetric):
|
|
55
55
|
inference_request = cls.create_inference_request(application_ref_name, session_id, reference_id, intent, False, False, completion_params, None, False, '')
|
|
56
56
|
if final_chunk:
|
|
57
57
|
chat_completion_response = chat_completion_chunk_to_response(final_chunk, content)
|
|
58
58
|
|
|
59
|
-
return ChatStorageRequest(chat_completion_request=inference_request, chat_completion_response=chat_completion_response)
|
|
59
|
+
return ChatStorageRequest(chat_completion_request=inference_request, chat_completion_response=chat_completion_response, timing_metrics=timing)
|
|
60
60
|
|
|
61
61
|
@classmethod
|
|
62
62
|
def store_chat_response(cls, session_id, reference_id, intent, application_ref_name, completion_params: ChatCompletionParams, chat_completion_response: Optional[ChatCompletionResponse],
|
|
63
|
-
final_chunk: Optional[ChatCompletionChunk], content: str):
|
|
64
|
-
chat_storage_request = cls.create_chat_storage_request(session_id, reference_id, intent, application_ref_name, completion_params, chat_completion_response, final_chunk, content)
|
|
63
|
+
final_chunk: Optional[ChatCompletionChunk], content: str, timing: RequestTimingMetric):
|
|
64
|
+
chat_storage_request = cls.create_chat_storage_request(session_id, reference_id, intent, application_ref_name, completion_params, chat_completion_response, final_chunk, content, timing)
|
|
65
65
|
cls.run_async(cls.send_storage_request_async(chat_storage_request))
|
|
66
66
|
|
|
67
67
|
@classmethod
|
|
@@ -304,8 +304,9 @@ class Completions:
|
|
|
304
304
|
|
|
305
305
|
)
|
|
306
306
|
if stream:
|
|
307
|
-
return _process_openai_stream(session_id, reference_id, intent, application_ref_name, messages, response, evaluation_enabled, completion_params, callback)
|
|
307
|
+
return _process_openai_stream(session_id, reference_id, intent, application_ref_name, messages, response, evaluation_enabled, completion_params, timing, callback)
|
|
308
308
|
else:
|
|
309
|
+
timing.time_request_end = time.time()
|
|
309
310
|
maitai_completion = convert_openai_chat_completion(response)
|
|
310
311
|
proto_messages = openai_messages_to_proto(messages)
|
|
311
312
|
proto_messages.append(
|
|
@@ -321,6 +322,7 @@ class Completions:
|
|
|
321
322
|
callback=callback,
|
|
322
323
|
chat_completion_response=maitai_completion,
|
|
323
324
|
completion_params=completion_params,
|
|
325
|
+
timing=timing,
|
|
324
326
|
)
|
|
325
327
|
else:
|
|
326
328
|
maitai.Inference.store_chat_response(
|
|
@@ -331,7 +333,8 @@ class Completions:
|
|
|
331
333
|
chat_completion_response=maitai_completion,
|
|
332
334
|
completion_params=completion_params,
|
|
333
335
|
final_chunk=None,
|
|
334
|
-
content=""
|
|
336
|
+
content="",
|
|
337
|
+
timing=timing,
|
|
335
338
|
)
|
|
336
339
|
return MaitaiCompletion(maitai_completion)
|
|
337
340
|
|
|
@@ -344,11 +347,15 @@ def _process_openai_stream(session_id: Union[str, int],
|
|
|
344
347
|
stream: openai.Stream[openai_chat_types.ChatCompletionChunk],
|
|
345
348
|
evaluation_enabled: bool,
|
|
346
349
|
chat_completion_params: ChatCompletionParams,
|
|
347
|
-
|
|
350
|
+
timing: RequestTimingMetric,
|
|
351
|
+
callback: Optional[EvaluateCallback] = None,
|
|
352
|
+
) -> Iterable[MaitaiChunk]:
|
|
348
353
|
full_body = ""
|
|
349
354
|
proto_messages = openai_messages_to_proto(messages)
|
|
350
355
|
last_chunk = None
|
|
351
356
|
for chunk in stream:
|
|
357
|
+
if last_chunk is None:
|
|
358
|
+
timing.time_first_chunk = time.time()
|
|
352
359
|
maitai_chunk = convert_open_ai_chat_completion_chunk(chunk)
|
|
353
360
|
if maitai_chunk.choices:
|
|
354
361
|
last_chunk = maitai_chunk
|
|
@@ -358,6 +365,7 @@ def _process_openai_stream(session_id: Union[str, int],
|
|
|
358
365
|
if maitai_chunk.usage and last_chunk is not None and not last_chunk.usage:
|
|
359
366
|
last_chunk.usage = maitai_chunk.usage
|
|
360
367
|
yield MaitaiChunk(maitai_chunk)
|
|
368
|
+
timing.time_request_end = time.time()
|
|
361
369
|
if evaluation_enabled:
|
|
362
370
|
proto_messages.append(ChatMessage(role="assistant", content=full_body))
|
|
363
371
|
Evaluator.evaluate(
|
|
@@ -370,6 +378,7 @@ def _process_openai_stream(session_id: Union[str, int],
|
|
|
370
378
|
callback=callback,
|
|
371
379
|
chat_completion_chunk=last_chunk,
|
|
372
380
|
completion_params=chat_completion_params,
|
|
381
|
+
timing=timing,
|
|
373
382
|
)
|
|
374
383
|
else:
|
|
375
384
|
maitai.Inference.store_chat_response(
|
|
@@ -381,6 +390,7 @@ def _process_openai_stream(session_id: Union[str, int],
|
|
|
381
390
|
final_chunk=last_chunk,
|
|
382
391
|
content=full_body,
|
|
383
392
|
chat_completion_response=None,
|
|
393
|
+
timing=timing,
|
|
384
394
|
)
|
|
385
395
|
|
|
386
396
|
|
|
@@ -299,8 +299,9 @@ class AsyncCompletions:
|
|
|
299
299
|
|
|
300
300
|
)
|
|
301
301
|
if stream:
|
|
302
|
-
return _process_async_openai_stream(session_id, reference_id, intent, application_ref_name, messages, response, evaluation_enabled, completion_params, callback)
|
|
302
|
+
return _process_async_openai_stream(session_id, reference_id, intent, application_ref_name, messages, response, evaluation_enabled, completion_params, timing, callback)
|
|
303
303
|
else:
|
|
304
|
+
timing.time_request_end = time.time()
|
|
304
305
|
maitai_completion = convert_openai_chat_completion(response)
|
|
305
306
|
proto_messages = openai_messages_to_proto(messages)
|
|
306
307
|
proto_messages.append(
|
|
@@ -316,6 +317,7 @@ class AsyncCompletions:
|
|
|
316
317
|
callback=callback,
|
|
317
318
|
chat_completion_response=maitai_completion,
|
|
318
319
|
completion_params=completion_params,
|
|
320
|
+
timing=timing,
|
|
319
321
|
)
|
|
320
322
|
else:
|
|
321
323
|
maitai.Inference.store_chat_response(
|
|
@@ -326,7 +328,8 @@ class AsyncCompletions:
|
|
|
326
328
|
chat_completion_response=maitai_completion,
|
|
327
329
|
completion_params=completion_params,
|
|
328
330
|
final_chunk=None,
|
|
329
|
-
content=""
|
|
331
|
+
content="",
|
|
332
|
+
timing=timing,
|
|
330
333
|
)
|
|
331
334
|
return MaitaiCompletion(maitai_completion)
|
|
332
335
|
|
|
@@ -339,11 +342,14 @@ async def _process_async_openai_stream(session_id: Union[str, int],
|
|
|
339
342
|
stream: openai.AsyncStream[openai_chat_types.ChatCompletionChunk],
|
|
340
343
|
evaluation_enabled: bool,
|
|
341
344
|
chat_completion_params: ChatCompletionParams,
|
|
345
|
+
timing: RequestTimingMetric,
|
|
342
346
|
callback: Optional[EvaluateCallback] = None) -> AsyncIterable[MaitaiChunk]:
|
|
343
347
|
full_body = ""
|
|
344
348
|
proto_messages = openai_messages_to_proto(messages)
|
|
345
349
|
last_chunk = None
|
|
346
350
|
async for chunk in stream:
|
|
351
|
+
if last_chunk is None:
|
|
352
|
+
timing.time_first_chunk = time.time()
|
|
347
353
|
maitai_chunk = convert_open_ai_chat_completion_chunk(chunk)
|
|
348
354
|
if maitai_chunk.choices:
|
|
349
355
|
last_chunk = maitai_chunk
|
|
@@ -353,6 +359,7 @@ async def _process_async_openai_stream(session_id: Union[str, int],
|
|
|
353
359
|
if maitai_chunk.usage and last_chunk is not None and not last_chunk.usage:
|
|
354
360
|
last_chunk.usage = maitai_chunk.usage
|
|
355
361
|
yield MaitaiChunk(maitai_chunk)
|
|
362
|
+
timing.time_request_end = time.time()
|
|
356
363
|
if last_chunk is None:
|
|
357
364
|
return
|
|
358
365
|
if evaluation_enabled:
|
|
@@ -367,6 +374,7 @@ async def _process_async_openai_stream(session_id: Union[str, int],
|
|
|
367
374
|
callback=callback,
|
|
368
375
|
chat_completion_chunk=last_chunk,
|
|
369
376
|
completion_params=chat_completion_params,
|
|
377
|
+
timing=timing,
|
|
370
378
|
)
|
|
371
379
|
else:
|
|
372
380
|
maitai.Inference.store_chat_response(
|
|
@@ -378,6 +386,7 @@ async def _process_async_openai_stream(session_id: Union[str, int],
|
|
|
378
386
|
final_chunk=last_chunk,
|
|
379
387
|
content=full_body,
|
|
380
388
|
chat_completion_response=None,
|
|
389
|
+
timing=timing,
|
|
381
390
|
)
|
|
382
391
|
|
|
383
392
|
|
|
@@ -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)
|
|
@@ -19,6 +19,7 @@ from betterproto.grpc.grpclib_server import ServiceBase
|
|
|
19
19
|
|
|
20
20
|
from .. import (
|
|
21
21
|
key as _key__,
|
|
22
|
+
metric as _metric__,
|
|
22
23
|
sentinel as _sentinel__,
|
|
23
24
|
)
|
|
24
25
|
|
|
@@ -40,11 +41,6 @@ class EvaluationContentType(betterproto.Enum):
|
|
|
40
41
|
PARTIAL = 2
|
|
41
42
|
|
|
42
43
|
|
|
43
|
-
class PromptStatus(betterproto.Enum):
|
|
44
|
-
BENIGN = 0
|
|
45
|
-
MALICIOUS = 1
|
|
46
|
-
|
|
47
|
-
|
|
48
44
|
@dataclass(eq=False, repr=False)
|
|
49
45
|
class ChatCompletionRequest(betterproto.Message):
|
|
50
46
|
params: "ChatCompletionParams" = betterproto.message_field(1)
|
|
@@ -290,6 +286,7 @@ class ChatStorageRequest(betterproto.Message):
|
|
|
290
286
|
chat_completion_request: "ChatCompletionRequest" = betterproto.message_field(1)
|
|
291
287
|
chat_completion_response: "ChatCompletionResponse" = betterproto.message_field(2)
|
|
292
288
|
evaluate_request: "EvaluateRequest" = betterproto.message_field(3)
|
|
289
|
+
timing_metrics: "_metric__.RequestTimingMetric" = betterproto.message_field(4)
|
|
293
290
|
|
|
294
291
|
|
|
295
292
|
@dataclass(eq=False, repr=False)
|
|
@@ -322,6 +319,7 @@ class EvaluateRequest(betterproto.Message):
|
|
|
322
319
|
partial: str = betterproto.string_field(20)
|
|
323
320
|
stream: bool = betterproto.bool_field(21)
|
|
324
321
|
apply_corrections: bool = betterproto.bool_field(22)
|
|
322
|
+
timing_metrics: "_metric__.RequestTimingMetric" = betterproto.message_field(23)
|
|
325
323
|
|
|
326
324
|
|
|
327
325
|
@dataclass(eq=False, repr=False)
|
|
@@ -361,19 +359,6 @@ class Turn(betterproto.Message):
|
|
|
361
359
|
eval_request: "EvaluateRequest" = betterproto.message_field(3)
|
|
362
360
|
|
|
363
361
|
|
|
364
|
-
@dataclass(eq=False, repr=False)
|
|
365
|
-
class PromptguardRequest(betterproto.Message):
|
|
366
|
-
company_id: int = betterproto.int64_field(1)
|
|
367
|
-
request_id: str = betterproto.string_field(2)
|
|
368
|
-
messages: List["ChatMessage"] = betterproto.message_field(3)
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
@dataclass(eq=False, repr=False)
|
|
372
|
-
class PromptguardResponse(betterproto.Message):
|
|
373
|
-
input_safety_score: float = betterproto.float_field(1)
|
|
374
|
-
status: "PromptStatus" = betterproto.enum_field(2)
|
|
375
|
-
|
|
376
|
-
|
|
377
362
|
@dataclass(eq=False, repr=False)
|
|
378
363
|
class SessionMessage(betterproto.Message):
|
|
379
364
|
id: int = betterproto.int64_field(1)
|
|
@@ -387,6 +372,23 @@ class SessionMessage(betterproto.Message):
|
|
|
387
372
|
date_created: int = betterproto.int64_field(9)
|
|
388
373
|
|
|
389
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
|
+
|
|
390
392
|
class EvaluationServiceStub(betterproto.ServiceStub):
|
|
391
393
|
async def evaluate(
|
|
392
394
|
self,
|
|
@@ -440,18 +442,18 @@ class EvaluationServiceStub(betterproto.ServiceStub):
|
|
|
440
442
|
metadata=metadata,
|
|
441
443
|
)
|
|
442
444
|
|
|
443
|
-
async def
|
|
445
|
+
async def backtest(
|
|
444
446
|
self,
|
|
445
|
-
|
|
447
|
+
backtest_evaluate_request: "BacktestEvaluateRequest",
|
|
446
448
|
*,
|
|
447
449
|
timeout: Optional[float] = None,
|
|
448
450
|
deadline: Optional["Deadline"] = None,
|
|
449
451
|
metadata: Optional["MetadataLike"] = None
|
|
450
|
-
) -> "
|
|
452
|
+
) -> "EvaluateResponse":
|
|
451
453
|
return await self._unary_unary(
|
|
452
|
-
"/chat.EvaluationService/
|
|
453
|
-
|
|
454
|
-
|
|
454
|
+
"/chat.EvaluationService/Backtest",
|
|
455
|
+
backtest_evaluate_request,
|
|
456
|
+
EvaluateResponse,
|
|
455
457
|
timeout=timeout,
|
|
456
458
|
deadline=deadline,
|
|
457
459
|
metadata=metadata,
|
|
@@ -474,9 +476,9 @@ class EvaluationServiceBase(ServiceBase):
|
|
|
474
476
|
) -> "betterproto_lib_google_protobuf.Empty":
|
|
475
477
|
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
476
478
|
|
|
477
|
-
async def
|
|
478
|
-
self,
|
|
479
|
-
) -> "
|
|
479
|
+
async def backtest(
|
|
480
|
+
self, backtest_evaluate_request: "BacktestEvaluateRequest"
|
|
481
|
+
) -> "EvaluateResponse":
|
|
480
482
|
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
481
483
|
|
|
482
484
|
async def __rpc_evaluate(
|
|
@@ -504,11 +506,11 @@ class EvaluationServiceBase(ServiceBase):
|
|
|
504
506
|
response = await self.evaluate_async(request)
|
|
505
507
|
await stream.send_message(response)
|
|
506
508
|
|
|
507
|
-
async def
|
|
508
|
-
self, stream: "grpclib.server.Stream[
|
|
509
|
+
async def __rpc_backtest(
|
|
510
|
+
self, stream: "grpclib.server.Stream[BacktestEvaluateRequest, EvaluateResponse]"
|
|
509
511
|
) -> None:
|
|
510
512
|
request = await stream.recv_message()
|
|
511
|
-
response = await self.
|
|
513
|
+
response = await self.backtest(request)
|
|
512
514
|
await stream.send_message(response)
|
|
513
515
|
|
|
514
516
|
def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
|
|
@@ -531,10 +533,10 @@ class EvaluationServiceBase(ServiceBase):
|
|
|
531
533
|
EvaluateRequest,
|
|
532
534
|
betterproto_lib_google_protobuf.Empty,
|
|
533
535
|
),
|
|
534
|
-
"/chat.EvaluationService/
|
|
535
|
-
self.
|
|
536
|
+
"/chat.EvaluationService/Backtest": grpclib.const.Handler(
|
|
537
|
+
self.__rpc_backtest,
|
|
536
538
|
grpclib.const.Cardinality.UNARY_UNARY,
|
|
537
|
-
|
|
538
|
-
|
|
539
|
+
BacktestEvaluateRequest,
|
|
540
|
+
EvaluateResponse,
|
|
539
541
|
),
|
|
540
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
|
{maitai_python-1.1.4b0 → 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
|