maitai-python 1.1.43b0__tar.gz → 1.1.44__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.43b0 → maitai_python-1.1.44}/PKG-INFO +1 -1
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/__init__.py +5 -1
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_azure.py +6 -12
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_config.py +16 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_config_listener_thread.py +1 -1
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_context.py +35 -20
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_maitai.py +14 -2
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_maitai_async.py +14 -2
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_maitai_client.py +8 -6
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_types.py +30 -2
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_common/version.py +1 -1
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/chat/__init__.py +3 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/config/__init__.py +2 -0
- maitai_python-1.1.44/maitai_gen/evaluation/__init__.py +38 -0
- {maitai_python-1.1.43b0/maitai_gen/annotation → maitai_python-1.1.44/maitai_gen/finetuning}/__init__.py +17 -1
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/model.py +1 -1
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/sentinel/__init__.py +7 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_python.egg-info/SOURCES.txt +2 -1
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/README.md +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_evaluator.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_inference.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/_utils.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai/tools/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_common/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_common/config/config_service.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/application/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/backtest/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/billing/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/company/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/embedding/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/event/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/inference/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/key/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/metric/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/notification/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/rates/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/sandbox/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_gen/session/__init__.py +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/setup.cfg +0 -0
- {maitai_python-1.1.43b0 → maitai_python-1.1.44}/setup.py +0 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
|
-
from maitai._azure import
|
|
3
|
+
from maitai._azure import (
|
|
4
|
+
MaitaiAsyncAzureOpenAIClient as AsyncAzureOpenAI,
|
|
5
|
+
MaitaiAzureOpenAIClient as AzureOpenAI,
|
|
6
|
+
)
|
|
4
7
|
from maitai._context import ContextManager
|
|
5
8
|
from maitai._evaluator import Evaluator as Evaluator
|
|
6
9
|
from maitai._inference import Inference as Inference
|
|
@@ -15,6 +18,7 @@ OpenAI = Maitai
|
|
|
15
18
|
|
|
16
19
|
def initialize(api_key):
|
|
17
20
|
from maitai._config import config
|
|
21
|
+
|
|
18
22
|
config.initialize(api_key)
|
|
19
23
|
|
|
20
24
|
|
|
@@ -31,8 +31,7 @@ class MaitaiAsyncAzureOpenAIClient:
|
|
|
31
31
|
default_query: Optional[Mapping[str, object]] = None,
|
|
32
32
|
http_client: Optional[httpx.AsyncClient] = None,
|
|
33
33
|
_strict_response_validation: bool = False,
|
|
34
|
-
) -> None:
|
|
35
|
-
...
|
|
34
|
+
) -> None: ...
|
|
36
35
|
|
|
37
36
|
@overload
|
|
38
37
|
def __init__(
|
|
@@ -52,8 +51,7 @@ class MaitaiAsyncAzureOpenAIClient:
|
|
|
52
51
|
default_query: Optional[Mapping[str, object]] = None,
|
|
53
52
|
http_client: Optional[httpx.AsyncClient] = None,
|
|
54
53
|
_strict_response_validation: bool = False,
|
|
55
|
-
) -> None:
|
|
56
|
-
...
|
|
54
|
+
) -> None: ...
|
|
57
55
|
|
|
58
56
|
@overload
|
|
59
57
|
def __init__(
|
|
@@ -73,8 +71,7 @@ class MaitaiAsyncAzureOpenAIClient:
|
|
|
73
71
|
default_query: Optional[Mapping[str, object]] = None,
|
|
74
72
|
http_client: Optional[httpx.AsyncClient] = None,
|
|
75
73
|
_strict_response_validation: bool = False,
|
|
76
|
-
) -> None:
|
|
77
|
-
...
|
|
74
|
+
) -> None: ...
|
|
78
75
|
|
|
79
76
|
def __init__(
|
|
80
77
|
self,
|
|
@@ -138,8 +135,7 @@ class MaitaiAzureOpenAIClient:
|
|
|
138
135
|
default_query: Optional[Mapping[str, object]] = None,
|
|
139
136
|
http_client: Optional[httpx.Client] = None,
|
|
140
137
|
_strict_response_validation: bool = False,
|
|
141
|
-
) -> None:
|
|
142
|
-
...
|
|
138
|
+
) -> None: ...
|
|
143
139
|
|
|
144
140
|
@overload
|
|
145
141
|
def __init__(
|
|
@@ -158,8 +154,7 @@ class MaitaiAzureOpenAIClient:
|
|
|
158
154
|
default_query: Optional[Mapping[str, object]] = None,
|
|
159
155
|
http_client: Optional[httpx.Client] = None,
|
|
160
156
|
_strict_response_validation: bool = False,
|
|
161
|
-
) -> None:
|
|
162
|
-
...
|
|
157
|
+
) -> None: ...
|
|
163
158
|
|
|
164
159
|
@overload
|
|
165
160
|
def __init__(
|
|
@@ -178,8 +173,7 @@ class MaitaiAzureOpenAIClient:
|
|
|
178
173
|
default_query: Optional[Mapping[str, object]] = None,
|
|
179
174
|
http_client: Optional[httpx.Client] = None,
|
|
180
175
|
_strict_response_validation: bool = False,
|
|
181
|
-
) -> None:
|
|
182
|
-
...
|
|
176
|
+
) -> None: ...
|
|
183
177
|
|
|
184
178
|
def __init__(
|
|
185
179
|
self,
|
|
@@ -45,6 +45,18 @@ def _get_gcp_instance_metadata(url, timeout=2):
|
|
|
45
45
|
return None
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
def _get_azure_instance_metadata(timeout=2):
|
|
49
|
+
try:
|
|
50
|
+
headers = {"Metadata": "true"}
|
|
51
|
+
url = "http://169.254.169.254/metadata/instance/compute?api-version=2021-02-01"
|
|
52
|
+
response = requests.get(url, headers=headers, timeout=timeout)
|
|
53
|
+
response.raise_for_status()
|
|
54
|
+
data = response.json()
|
|
55
|
+
return data.get("location")
|
|
56
|
+
except requests.RequestException:
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
|
|
48
60
|
def _determine_maitai_host():
|
|
49
61
|
if maitai_host := os.environ.get("MAITAI_HOST"):
|
|
50
62
|
return maitai_host.rstrip("/")
|
|
@@ -66,6 +78,10 @@ def _determine_maitai_host():
|
|
|
66
78
|
elif "us-central1" in gcp_zone:
|
|
67
79
|
return "https://api.gcp.us-central1.trymaitai.ai"
|
|
68
80
|
|
|
81
|
+
# azure_region = _get_azure_instance_metadata()
|
|
82
|
+
# if azure_region == "westus2":
|
|
83
|
+
# return "https://api.azure.westus2.trymaitai.ai"
|
|
84
|
+
|
|
69
85
|
return "https://api.trymaitai.ai"
|
|
70
86
|
|
|
71
87
|
|
|
@@ -11,7 +11,7 @@ class ConfigListenerThread(WebsocketListenerThread):
|
|
|
11
11
|
|
|
12
12
|
def on_message(self, ws, message):
|
|
13
13
|
event = json.loads(message)
|
|
14
|
-
if event.get("event_type") ==
|
|
14
|
+
if event.get("event_type") == "APPLICATION_CONFIG_CHANGE":
|
|
15
15
|
application_json = event.get("event_data")
|
|
16
16
|
if application_json:
|
|
17
17
|
try:
|
|
@@ -10,9 +10,18 @@ from maitai_gen.application import ApplicationContext
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class ContextManager:
|
|
13
|
-
@required_args(
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
@required_args(
|
|
14
|
+
["application", "reference", "context_body"],
|
|
15
|
+
["application", "reference", "file_path"],
|
|
16
|
+
)
|
|
17
|
+
def update(
|
|
18
|
+
self,
|
|
19
|
+
*,
|
|
20
|
+
application: str,
|
|
21
|
+
reference: str,
|
|
22
|
+
context_body: str = "",
|
|
23
|
+
file_path: str = "",
|
|
24
|
+
):
|
|
16
25
|
if not reference:
|
|
17
26
|
raise ValueError("Reference is required")
|
|
18
27
|
if context_body and file_path:
|
|
@@ -21,39 +30,45 @@ class ContextManager:
|
|
|
21
30
|
context = ApplicationContext()
|
|
22
31
|
context.reference = reference
|
|
23
32
|
if file_path:
|
|
24
|
-
s3_path = self.upload_context_file(file_path).get(
|
|
33
|
+
s3_path = self.upload_context_file(file_path).get("s3_path")
|
|
25
34
|
if not s3_path:
|
|
26
|
-
raise Exception(
|
|
27
|
-
context.context_type =
|
|
35
|
+
raise Exception("Failed to upload context")
|
|
36
|
+
context.context_type = "FILE"
|
|
28
37
|
context.context_path = s3_path
|
|
29
38
|
else:
|
|
30
39
|
context.context_body = context_body
|
|
31
|
-
context.context_type =
|
|
40
|
+
context.context_type = "TEXT"
|
|
32
41
|
|
|
33
42
|
host = config.maitai_host
|
|
34
|
-
url = f
|
|
43
|
+
url = f"{host}/context/application"
|
|
35
44
|
headers = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
"Content-Type": "application/json",
|
|
46
|
+
"x-api-key": config.api_key,
|
|
47
|
+
"x-client-version": version,
|
|
39
48
|
}
|
|
40
|
-
response = requests.put(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
response = requests.put(
|
|
50
|
+
url,
|
|
51
|
+
headers=headers,
|
|
52
|
+
data=json.dumps(
|
|
53
|
+
{
|
|
54
|
+
"application_ref_name": application,
|
|
55
|
+
"context": context.to_pydict(casing=Casing.SNAKE),
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
)
|
|
44
59
|
|
|
45
60
|
if response.status_code != 200:
|
|
46
61
|
raise RuntimeError(f"Error updating context: {response.text}")
|
|
47
62
|
|
|
48
63
|
def upload_context_file(self, file_path: str):
|
|
49
64
|
host = config.maitai_host
|
|
50
|
-
url = f
|
|
65
|
+
url = f"{host}/context/application/file"
|
|
51
66
|
headers = {
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
"x-api-key": config.api_key,
|
|
68
|
+
"x-client-version": version,
|
|
54
69
|
}
|
|
55
|
-
with open(file_path,
|
|
56
|
-
files = {
|
|
70
|
+
with open(file_path, "rb") as file:
|
|
71
|
+
files = {"file": file}
|
|
57
72
|
response = requests.post(url, headers=headers, files=files)
|
|
58
73
|
if response.status_code != 200:
|
|
59
74
|
raise RuntimeError(f"Error uploading context: {response.text}")
|
|
@@ -27,6 +27,7 @@ from maitai._types import (
|
|
|
27
27
|
ToolFunction,
|
|
28
28
|
)
|
|
29
29
|
from maitai._utils import (
|
|
30
|
+
OpenAISchemaGenerator,
|
|
30
31
|
convert_open_ai_chat_completion_chunk,
|
|
31
32
|
convert_openai_chat_completion,
|
|
32
33
|
get_chat_completion_params,
|
|
@@ -350,7 +351,9 @@ class Completions:
|
|
|
350
351
|
timing.request_id = resp.chat_completion_response.request_id
|
|
351
352
|
timing.time_request_end = time.time()
|
|
352
353
|
maitai.Inference.store_request_timing_data(timing)
|
|
353
|
-
return MaitaiCompletion(
|
|
354
|
+
return MaitaiCompletion(
|
|
355
|
+
resp.chat_completion_response, response_format=response_format
|
|
356
|
+
)
|
|
354
357
|
raise InferenceException("No data received")
|
|
355
358
|
except MaitaiConnectionError as e:
|
|
356
359
|
if "gpt" not in model and fallback_model and "gpt" in fallback_model:
|
|
@@ -366,6 +369,13 @@ class Completions:
|
|
|
366
369
|
default_headers=self._client_params.default_headers or None,
|
|
367
370
|
base_url=self._client_params.base_url or None,
|
|
368
371
|
)
|
|
372
|
+
if hasattr(response_format, "model_json_schema"):
|
|
373
|
+
response_format = {
|
|
374
|
+
"type": "json_schema",
|
|
375
|
+
"json_schema": response_format.model_json_schema(
|
|
376
|
+
schema_generator=OpenAISchemaGenerator, mode="serialization"
|
|
377
|
+
),
|
|
378
|
+
}
|
|
369
379
|
response = self._client.chat.completions.create(
|
|
370
380
|
messages=messages,
|
|
371
381
|
model=model,
|
|
@@ -444,7 +454,9 @@ class Completions:
|
|
|
444
454
|
timing=timing,
|
|
445
455
|
metadata=metadata,
|
|
446
456
|
)
|
|
447
|
-
return MaitaiCompletion(
|
|
457
|
+
return MaitaiCompletion(
|
|
458
|
+
maitai_completion, response_format=response_format
|
|
459
|
+
)
|
|
448
460
|
|
|
449
461
|
|
|
450
462
|
def _process_openai_stream(
|
|
@@ -27,6 +27,7 @@ from maitai._types import (
|
|
|
27
27
|
ToolFunction,
|
|
28
28
|
)
|
|
29
29
|
from maitai._utils import (
|
|
30
|
+
OpenAISchemaGenerator,
|
|
30
31
|
convert_open_ai_chat_completion_chunk,
|
|
31
32
|
convert_openai_chat_completion,
|
|
32
33
|
get_chat_completion_params,
|
|
@@ -347,7 +348,9 @@ class AsyncCompletions:
|
|
|
347
348
|
timing.request_id = resp.chat_completion_response.request_id
|
|
348
349
|
timing.time_request_end = time.time()
|
|
349
350
|
maitai.Inference.store_request_timing_data(timing)
|
|
350
|
-
return MaitaiCompletion(
|
|
351
|
+
return MaitaiCompletion(
|
|
352
|
+
resp.chat_completion_response, response_format=response_format
|
|
353
|
+
)
|
|
351
354
|
raise InferenceException("No data received")
|
|
352
355
|
except MaitaiConnectionError as e:
|
|
353
356
|
if "gpt" not in model and fallback_model and "gpt" in fallback_model:
|
|
@@ -363,6 +366,13 @@ class AsyncCompletions:
|
|
|
363
366
|
default_query=self._client_params.default_query or None,
|
|
364
367
|
base_url=self._client_params.base_url or None,
|
|
365
368
|
)
|
|
369
|
+
if hasattr(response_format, "model_json_schema"):
|
|
370
|
+
response_format = {
|
|
371
|
+
"type": "json_schema",
|
|
372
|
+
"json_schema": response_format.model_json_schema(
|
|
373
|
+
schema_generator=OpenAISchemaGenerator, mode="serialization"
|
|
374
|
+
),
|
|
375
|
+
}
|
|
366
376
|
response = await self._client.chat.completions.create(
|
|
367
377
|
messages=messages,
|
|
368
378
|
model=model,
|
|
@@ -441,7 +451,9 @@ class AsyncCompletions:
|
|
|
441
451
|
timing=timing,
|
|
442
452
|
metadata=metadata,
|
|
443
453
|
)
|
|
444
|
-
return MaitaiCompletion(
|
|
454
|
+
return MaitaiCompletion(
|
|
455
|
+
maitai_completion, response_format=response_format
|
|
456
|
+
)
|
|
445
457
|
|
|
446
458
|
|
|
447
459
|
async def _process_async_openai_stream(
|
|
@@ -26,7 +26,7 @@ class MaitaiClient:
|
|
|
26
26
|
|
|
27
27
|
if loop and loop.is_running():
|
|
28
28
|
# We are in an asyncio loop, schedule coroutine execution
|
|
29
|
-
asyncio.create_task(coro, name=
|
|
29
|
+
asyncio.create_task(coro, name="maitai")
|
|
30
30
|
else:
|
|
31
31
|
# Not in an asyncio loop, run in a new event loop in a background thread
|
|
32
32
|
def run():
|
|
@@ -44,11 +44,11 @@ class MaitaiClient:
|
|
|
44
44
|
@classmethod
|
|
45
45
|
async def increment_error(cls, error: str, path: str):
|
|
46
46
|
host = config.maitai_host
|
|
47
|
-
url = f
|
|
47
|
+
url = f"{host}/metrics/increment/python_sdk_error"
|
|
48
48
|
headers = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
"Content-Type": "application/json",
|
|
50
|
+
"x-api-key": config.api_key,
|
|
51
|
+
"x-client-version": version,
|
|
52
52
|
}
|
|
53
53
|
labels = {
|
|
54
54
|
"cause": error,
|
|
@@ -56,7 +56,9 @@ class MaitaiClient:
|
|
|
56
56
|
"path": path,
|
|
57
57
|
}
|
|
58
58
|
try:
|
|
59
|
-
async with aiohttp.ClientSession(
|
|
59
|
+
async with aiohttp.ClientSession(
|
|
60
|
+
connector=aiohttp.TCPConnector(ssl=False)
|
|
61
|
+
) as session:
|
|
60
62
|
return await session.put(url, headers=headers, data=json.dumps(labels))
|
|
61
63
|
except:
|
|
62
64
|
pass
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import json
|
|
3
3
|
import queue
|
|
4
|
-
from typing import Any, Callable, Mapping, Protocol, Union
|
|
4
|
+
from typing import Any, Callable, Mapping, Optional, Protocol, Union
|
|
5
5
|
|
|
6
6
|
import openai.types.chat as openai_chat_types
|
|
7
7
|
from betterproto import Casing
|
|
8
|
+
from pydantic import BaseModel
|
|
8
9
|
from typing_extensions import Literal, runtime_checkable
|
|
9
10
|
|
|
10
11
|
import maitai_gen.chat as chat_types
|
|
@@ -57,12 +58,20 @@ class MaitaiChunk(ChatCompletionChunk):
|
|
|
57
58
|
|
|
58
59
|
|
|
59
60
|
class MaitaiCompletion(ChatCompletionResponse):
|
|
60
|
-
def __init__(
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
chat_completion_response: ChatCompletionResponse = None,
|
|
64
|
+
response_format: Optional[BaseModel] = None,
|
|
65
|
+
):
|
|
61
66
|
super().__init__()
|
|
62
67
|
if chat_completion_response is not None:
|
|
63
68
|
if chat_completion_response.chat_completion_request is not None:
|
|
64
69
|
self.chat_completion_request = ChatCompletionRequest()
|
|
65
70
|
self.from_pydict(chat_completion_response.to_pydict())
|
|
71
|
+
for choice in self.choices:
|
|
72
|
+
choice.message = MaitaiMessage(
|
|
73
|
+
choice.message, response_format=response_format
|
|
74
|
+
)
|
|
66
75
|
|
|
67
76
|
def model_dump_json(self):
|
|
68
77
|
return json.dumps(self.to_pydict(casing=Casing.SNAKE))
|
|
@@ -80,6 +89,25 @@ class MaitaiCompletion(ChatCompletionResponse):
|
|
|
80
89
|
return openai_chat_types.ChatCompletion(**data).model_dump_json()
|
|
81
90
|
|
|
82
91
|
|
|
92
|
+
class MaitaiMessage(ChatCompletionMessage):
|
|
93
|
+
def __init__(
|
|
94
|
+
self,
|
|
95
|
+
chat_completion_message: ChatCompletionMessage = None,
|
|
96
|
+
response_format: Optional[BaseModel] = None,
|
|
97
|
+
):
|
|
98
|
+
super().__init__()
|
|
99
|
+
if chat_completion_message is not None:
|
|
100
|
+
self.from_pydict(chat_completion_message.to_pydict())
|
|
101
|
+
self.response_format = response_format
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def parsed(self) -> Any:
|
|
105
|
+
content = json.loads(self.content)
|
|
106
|
+
if self.response_format:
|
|
107
|
+
return self.response_format.model_validate(content)
|
|
108
|
+
return content
|
|
109
|
+
|
|
110
|
+
|
|
83
111
|
@runtime_checkable
|
|
84
112
|
class ToolFunction(Protocol):
|
|
85
113
|
__name__: str
|
|
@@ -364,6 +364,8 @@ class EvaluateRequest(betterproto.Message):
|
|
|
364
364
|
tools: List["Tool"] = betterproto.message_field(24)
|
|
365
365
|
sentinels: List["_sentinel__.Sentinel"] = betterproto.message_field(25)
|
|
366
366
|
evaluation_request_id: str = betterproto.string_field(26)
|
|
367
|
+
json_schema: Optional["JsonSchema"] = betterproto.message_field(27, optional=True)
|
|
368
|
+
evaluation_run_id: Optional[int] = betterproto.int64_field(28, optional=True)
|
|
367
369
|
|
|
368
370
|
|
|
369
371
|
@dataclass(eq=False, repr=False)
|
|
@@ -448,6 +450,7 @@ class BacktestEvaluateRequest(betterproto.Message):
|
|
|
448
450
|
response_message: "ChatCompletionMessage" = betterproto.message_field(12)
|
|
449
451
|
sentinels: List["_sentinel__.Sentinel"] = betterproto.message_field(13)
|
|
450
452
|
tools: List["Tool"] = betterproto.message_field(14)
|
|
453
|
+
json_schema: Optional["JsonSchema"] = betterproto.message_field(15, optional=True)
|
|
451
454
|
|
|
452
455
|
|
|
453
456
|
class EvaluationServiceStub(betterproto.ServiceStub):
|
|
@@ -38,6 +38,8 @@ class Config(betterproto.Message):
|
|
|
38
38
|
intent_stability: Optional[str] = betterproto.string_field(20, optional=True)
|
|
39
39
|
safe_mode: bool = betterproto.bool_field(21)
|
|
40
40
|
feedback: List[str] = betterproto.string_field(22)
|
|
41
|
+
generating_sentinels: bool = betterproto.bool_field(23)
|
|
42
|
+
sentinel_regeneration_enabled: bool = betterproto.bool_field(24)
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
@dataclass(eq=False, repr=False)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# sources: evaluation.proto
|
|
3
|
+
# plugin: python-betterproto
|
|
4
|
+
# This file has been @generated
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import (
|
|
8
|
+
Dict,
|
|
9
|
+
List,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
import betterproto
|
|
13
|
+
|
|
14
|
+
from .. import (
|
|
15
|
+
application as _application__,
|
|
16
|
+
chat as _chat__,
|
|
17
|
+
sentinel as _sentinel__,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(eq=False, repr=False)
|
|
22
|
+
class EvaluationRun(betterproto.Message):
|
|
23
|
+
id: int = betterproto.int64_field(1)
|
|
24
|
+
company_id: int = betterproto.int64_field(2)
|
|
25
|
+
application_id: int = betterproto.int64_field(3)
|
|
26
|
+
intent_id: int = betterproto.int64_field(4)
|
|
27
|
+
application: "_application__.Application" = betterproto.message_field(5)
|
|
28
|
+
intent: "_application__.ApplicationAction" = betterproto.message_field(6)
|
|
29
|
+
date_created: int = betterproto.int64_field(7)
|
|
30
|
+
date_start: int = betterproto.int64_field(8)
|
|
31
|
+
date_end: int = betterproto.int64_field(9)
|
|
32
|
+
sentinels: List["_sentinel__.Sentinel"] = betterproto.message_field(10)
|
|
33
|
+
status: str = betterproto.string_field(11)
|
|
34
|
+
meta: Dict[str, str] = betterproto.map_field(
|
|
35
|
+
12, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
|
36
|
+
)
|
|
37
|
+
request_count: int = betterproto.int64_field(13)
|
|
38
|
+
requests: List["_chat__.EvaluateRequest"] = betterproto.message_field(14)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
-
# sources:
|
|
2
|
+
# sources: finetuning.proto
|
|
3
3
|
# plugin: python-betterproto
|
|
4
4
|
# This file has been @generated
|
|
5
5
|
|
|
@@ -63,3 +63,19 @@ class ExportRequest(betterproto.Message):
|
|
|
63
63
|
remove_example_tag: bool = betterproto.bool_field(4)
|
|
64
64
|
remove_output_tag: bool = betterproto.bool_field(5)
|
|
65
65
|
train_split: float = betterproto.float_field(6)
|
|
66
|
+
conversation_mode: bool = betterproto.bool_field(7)
|
|
67
|
+
fourbit: bool = betterproto.bool_field(8)
|
|
68
|
+
run_name: Optional[str] = betterproto.string_field(9, optional=True)
|
|
69
|
+
base_model: str = betterproto.string_field(10)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass(eq=False, repr=False)
|
|
73
|
+
class FinetuneRequest(betterproto.Message):
|
|
74
|
+
input_file: str = betterproto.string_field(1)
|
|
75
|
+
run_name: str = betterproto.string_field(2)
|
|
76
|
+
conversation_mode: bool = betterproto.bool_field(3)
|
|
77
|
+
fourbit: bool = betterproto.bool_field(4)
|
|
78
|
+
prompt: Optional[str] = betterproto.string_field(5, optional=True)
|
|
79
|
+
max_steps: Optional[int] = betterproto.int32_field(6, optional=True)
|
|
80
|
+
run_id: int = betterproto.int64_field(7)
|
|
81
|
+
base_model: str = betterproto.string_field(8)
|
|
@@ -33,6 +33,7 @@ class Sentinel(betterproto.Message):
|
|
|
33
33
|
9, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
|
34
34
|
)
|
|
35
35
|
sentinel_generation_id: int = betterproto.int64_field(10)
|
|
36
|
+
qa: List["SentinelQa"] = betterproto.message_field(11)
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
@dataclass(eq=False, repr=False)
|
|
@@ -44,6 +45,12 @@ class SentinelDirective(betterproto.Message):
|
|
|
44
45
|
examples: List["SentinelExample"] = betterproto.message_field(5)
|
|
45
46
|
|
|
46
47
|
|
|
48
|
+
@dataclass(eq=False, repr=False)
|
|
49
|
+
class SentinelQa(betterproto.Message):
|
|
50
|
+
question: str = betterproto.string_field(1)
|
|
51
|
+
answer: str = betterproto.string_field(2)
|
|
52
|
+
|
|
53
|
+
|
|
47
54
|
@dataclass(eq=False, repr=False)
|
|
48
55
|
class DirectiveBody(betterproto.Message):
|
|
49
56
|
main: str = betterproto.string_field(1)
|
|
@@ -22,7 +22,6 @@ maitai_common/processes/io_thread.py
|
|
|
22
22
|
maitai_common/processes/websocket_listener_thread.py
|
|
23
23
|
maitai_gen/__init__.py
|
|
24
24
|
maitai_gen/model.py
|
|
25
|
-
maitai_gen/annotation/__init__.py
|
|
26
25
|
maitai_gen/application/__init__.py
|
|
27
26
|
maitai_gen/backtest/__init__.py
|
|
28
27
|
maitai_gen/billing/__init__.py
|
|
@@ -30,7 +29,9 @@ maitai_gen/chat/__init__.py
|
|
|
30
29
|
maitai_gen/company/__init__.py
|
|
31
30
|
maitai_gen/config/__init__.py
|
|
32
31
|
maitai_gen/embedding/__init__.py
|
|
32
|
+
maitai_gen/evaluation/__init__.py
|
|
33
33
|
maitai_gen/event/__init__.py
|
|
34
|
+
maitai_gen/finetuning/__init__.py
|
|
34
35
|
maitai_gen/inference/__init__.py
|
|
35
36
|
maitai_gen/key/__init__.py
|
|
36
37
|
maitai_gen/metric/__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
|
{maitai_python-1.1.43b0 → maitai_python-1.1.44}/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
|