maitai-python 1.0.4__py3-none-any.whl → 1.0.6__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/__init__.py +3 -3
- maitai/_azure.py +1 -1
- maitai/_config.py +16 -1
- maitai/_evaluator.py +10 -181
- maitai/_inference.py +15 -15
- maitai/_maitai_client.py +1 -1
- maitai/_openai.py +73 -58
- maitai/_openai_async.py +75 -58
- maitai/_utils.py +1 -34
- maitai_common/config/__init__.py +0 -0
- maitai_common/config/config_service.py +51 -0
- maitai_gen/application/__init__.py +19 -2
- maitai_gen/chat/__init__.py +5 -3
- maitai_gen/config/__init__.py +31 -0
- maitai_gen/sandbox/__init__.py +6 -3
- maitai_gen/sentinel/__init__.py +7 -0
- maitai_gen/session/__init__.py +1 -1
- {maitai_python-1.0.4.dist-info → maitai_python-1.0.6.dist-info}/METADATA +2 -2
- maitai_python-1.0.6.dist-info/RECORD +35 -0
- maitai_python-1.0.4.dist-info/RECORD +0 -32
- {maitai_python-1.0.4.dist-info → maitai_python-1.0.6.dist-info}/WHEEL +0 -0
- {maitai_python-1.0.4.dist-info → maitai_python-1.0.6.dist-info}/top_level.txt +0 -0
maitai/__init__.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
3
|
import maitai._types as types
|
|
4
|
-
from maitai._azure import
|
|
4
|
+
from maitai._azure import MaitaiAsyncAzureOpenAIClient as AsyncAzureOpenAI, MaitaiAzureOpenAIClient as AzureOpenAI
|
|
5
5
|
from maitai._evaluator import Evaluator as Evaluator
|
|
6
6
|
from maitai._inference import Inference as Inference
|
|
7
|
-
from maitai._openai import
|
|
8
|
-
from maitai._openai_async import
|
|
7
|
+
from maitai._openai import MaitaiOpenAIClient as OpenAI
|
|
8
|
+
from maitai._openai_async import MaitaiAsyncOpenAIClient as AsyncOpenAI
|
|
9
9
|
|
|
10
10
|
chat = OpenAI().chat
|
|
11
11
|
|
maitai/_azure.py
CHANGED
maitai/_config.py
CHANGED
|
@@ -3,7 +3,9 @@ import os
|
|
|
3
3
|
import requests
|
|
4
4
|
|
|
5
5
|
from maitai._config_listener_thread import ConfigListenerThread
|
|
6
|
+
from maitai_common.config import config_service
|
|
6
7
|
from maitai_gen.application import Application
|
|
8
|
+
from maitai_gen.config import Config as ActionConfig
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
class Config:
|
|
@@ -16,11 +18,16 @@ class Config:
|
|
|
16
18
|
self._company_id = None
|
|
17
19
|
self.websocket_listener_thread = None
|
|
18
20
|
self.config_listener_thread = None
|
|
21
|
+
self._application_action_configs: dict[str, dict[str, ActionConfig]] = {}
|
|
22
|
+
self.initialized = False
|
|
19
23
|
|
|
20
24
|
@property
|
|
21
25
|
def api_key(self):
|
|
22
26
|
if self._api_key is None:
|
|
23
|
-
|
|
27
|
+
if self.initialized:
|
|
28
|
+
raise ValueError("Maitai API Key has not been set")
|
|
29
|
+
else:
|
|
30
|
+
self.initialize(api_key=os.environ.get("MAITAI_API_KEY"))
|
|
24
31
|
return self._api_key
|
|
25
32
|
|
|
26
33
|
@api_key.setter
|
|
@@ -32,10 +39,14 @@ class Config:
|
|
|
32
39
|
self._initialize_company()
|
|
33
40
|
self.refresh_applications()
|
|
34
41
|
self._initialize_websocket()
|
|
42
|
+
self.initialized = True
|
|
35
43
|
|
|
36
44
|
def get_application(self, application_ref_name: str) -> Application:
|
|
37
45
|
return self._applications.get(application_ref_name)
|
|
38
46
|
|
|
47
|
+
def get_application_action_config(self, application_ref_name: str, action_type: str) -> ActionConfig:
|
|
48
|
+
return self._application_action_configs.get(application_ref_name, {}).get(action_type, config_service.get_default_config())
|
|
49
|
+
|
|
39
50
|
def _initialize_company(self):
|
|
40
51
|
host = self.maitai_host
|
|
41
52
|
url = f'{host}/company/'
|
|
@@ -59,6 +70,10 @@ class Config:
|
|
|
59
70
|
applications = [Application().from_dict(app_json) for app_json in response.json()]
|
|
60
71
|
for application in applications:
|
|
61
72
|
self._applications[application.application_ref_name] = application
|
|
73
|
+
for action_type in application.action_types:
|
|
74
|
+
if application.application_ref_name not in self._application_action_configs:
|
|
75
|
+
self._application_action_configs[application.application_ref_name] = {}
|
|
76
|
+
self._application_action_configs[application.application_ref_name][action_type.action_type] = action_type.meta
|
|
62
77
|
|
|
63
78
|
def _initialize_websocket(self):
|
|
64
79
|
self.config_listener_thread = ConfigListenerThread(self, self.maitai_ws, "APPLICATION_CONFIG_CHANGE", self._company_id)
|
maitai/_evaluator.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import asyncio
|
|
2
|
+
import traceback
|
|
2
3
|
from typing import Iterable
|
|
3
4
|
|
|
4
5
|
import aiohttp
|
|
@@ -6,7 +7,7 @@ import requests
|
|
|
6
7
|
from betterproto import Casing
|
|
7
8
|
|
|
8
9
|
from maitai._config import config
|
|
9
|
-
from maitai._maitai_client import
|
|
10
|
+
from maitai._maitai_client import MaitaiClient
|
|
10
11
|
from maitai._types import EvaluateCallback
|
|
11
12
|
from maitai_gen.chat import ChatCompletionChunk, EvaluateRequest, EvaluateResponse, EvaluationContentType
|
|
12
13
|
|
|
@@ -20,7 +21,7 @@ def _get_content_type(content, partial=None):
|
|
|
20
21
|
return EvaluationContentType.MESSAGE
|
|
21
22
|
|
|
22
23
|
|
|
23
|
-
class Evaluator(
|
|
24
|
+
class Evaluator(MaitaiClient):
|
|
24
25
|
|
|
25
26
|
def __init__(self):
|
|
26
27
|
super().__init__()
|
|
@@ -34,11 +35,7 @@ class Evaluator(MaiTaiClient):
|
|
|
34
35
|
if application_id is None and application_ref_name is None:
|
|
35
36
|
raise Exception('application_id or application_ref_name must be provided')
|
|
36
37
|
eval_request: EvaluateRequest = cls.create_eval_request(application_id, application_ref_name, session_id, reference_id, action_type, content_type, content)
|
|
37
|
-
|
|
38
|
-
return await cls.send_evaluation_request_async(eval_request)
|
|
39
|
-
else:
|
|
40
|
-
cls.run_async(cls.send_evaluation_request_async(eval_request, callback))
|
|
41
|
-
return None
|
|
38
|
+
await asyncio.create_task(cls.send_evaluation_request_async(eval_request, callback))
|
|
42
39
|
|
|
43
40
|
@classmethod
|
|
44
41
|
def evaluate(cls, session_id, reference_id, action_type, content, content_type=None, application_id=None, application_ref_name=None, callback=None, partial=None):
|
|
@@ -49,11 +46,7 @@ class Evaluator(MaiTaiClient):
|
|
|
49
46
|
if application_id is None and application_ref_name is None:
|
|
50
47
|
raise Exception('application_id or application_ref_name must be provided')
|
|
51
48
|
eval_request: EvaluateRequest = cls.create_eval_request(application_id, application_ref_name, session_id, reference_id, action_type, content_type, content, partial=partial)
|
|
52
|
-
|
|
53
|
-
return cls.send_evaluation_request(eval_request)
|
|
54
|
-
else:
|
|
55
|
-
cls.run_async(cls.send_evaluation_request_async(eval_request, callback))
|
|
56
|
-
return None
|
|
49
|
+
cls.run_async(cls.send_evaluation_request_async(eval_request, callback))
|
|
57
50
|
|
|
58
51
|
@classmethod
|
|
59
52
|
def evaluate_realtime(cls, session_id, reference_id, action_type, content_type, content, application_ref_name, partial, fault_description, sentinel_id):
|
|
@@ -85,60 +78,6 @@ class Evaluator(MaiTaiClient):
|
|
|
85
78
|
eval_request.fault_description = fault_description
|
|
86
79
|
return eval_request
|
|
87
80
|
|
|
88
|
-
@classmethod
|
|
89
|
-
def update_session_context(cls, session_id, context, application_id=None, application_ref_name=None):
|
|
90
|
-
if type(context) != dict:
|
|
91
|
-
raise Exception('Context must be a dictionary')
|
|
92
|
-
if application_id is None and application_ref_name is None:
|
|
93
|
-
raise Exception('application_id or application_ref_name must be provided')
|
|
94
|
-
session_context = {
|
|
95
|
-
'application_id': application_id,
|
|
96
|
-
'application_ref_name': application_ref_name,
|
|
97
|
-
'session_id': session_id,
|
|
98
|
-
'context': context
|
|
99
|
-
}
|
|
100
|
-
cls.run_async(cls.send_session_context_update(session_context))
|
|
101
|
-
|
|
102
|
-
@classmethod
|
|
103
|
-
def append_session_context(cls, session_id, context, application_id=None, application_ref_name=None):
|
|
104
|
-
if type(context) != dict:
|
|
105
|
-
raise Exception('Context must be a dictionary')
|
|
106
|
-
if application_id is None and application_ref_name is None:
|
|
107
|
-
raise Exception('application_id or application_ref_name must be provided')
|
|
108
|
-
session_context = {
|
|
109
|
-
'application_id': application_id,
|
|
110
|
-
'application_ref_name': application_ref_name,
|
|
111
|
-
'session_id': session_id,
|
|
112
|
-
'context': context
|
|
113
|
-
}
|
|
114
|
-
cls.run_async(cls.send_session_context_append(session_context))
|
|
115
|
-
|
|
116
|
-
@classmethod
|
|
117
|
-
def update_application_context(cls, context, application_id=None, application_ref_name=None):
|
|
118
|
-
if type(context) != dict:
|
|
119
|
-
raise Exception('Context must be a dictionary')
|
|
120
|
-
if application_id is None and application_ref_name is None:
|
|
121
|
-
raise Exception('application_id or application_ref_name must be provided')
|
|
122
|
-
application_context = {
|
|
123
|
-
'application_id': application_id,
|
|
124
|
-
'application_ref_name': application_ref_name,
|
|
125
|
-
'context': context
|
|
126
|
-
}
|
|
127
|
-
cls.run_async(cls.send_application_context_update(application_context))
|
|
128
|
-
|
|
129
|
-
@classmethod
|
|
130
|
-
def append_application_context(cls, context, application_id=None, application_ref_name=None):
|
|
131
|
-
if type(context) != dict:
|
|
132
|
-
raise Exception('Context must be a dictionary')
|
|
133
|
-
if application_id is None and application_ref_name is None:
|
|
134
|
-
raise Exception('application_id or application_ref_name must be provided')
|
|
135
|
-
application_context = {
|
|
136
|
-
'application_id': application_id,
|
|
137
|
-
'application_ref_name': application_ref_name,
|
|
138
|
-
'context': context
|
|
139
|
-
}
|
|
140
|
-
cls.run_async(cls.send_application_context_append(application_context))
|
|
141
|
-
|
|
142
81
|
@classmethod
|
|
143
82
|
async def send_evaluation_request_async(cls, eval_request: EvaluateRequest, callback: EvaluateCallback = None):
|
|
144
83
|
async def send_request():
|
|
@@ -161,123 +100,13 @@ class Evaluator(MaiTaiClient):
|
|
|
161
100
|
if result is not None:
|
|
162
101
|
eval_result = EvaluateResponse().from_json(result)
|
|
163
102
|
if callback is not None:
|
|
164
|
-
|
|
103
|
+
try:
|
|
104
|
+
callback(eval_result)
|
|
105
|
+
except:
|
|
106
|
+
traceback.print_exc()
|
|
165
107
|
else:
|
|
166
108
|
return eval_result
|
|
167
109
|
|
|
168
|
-
@classmethod
|
|
169
|
-
def send_evaluation_request(cls, eval_request: EvaluateRequest) -> EvaluateResponse:
|
|
170
|
-
def send_request():
|
|
171
|
-
host = config.maitai_host
|
|
172
|
-
url = f'{host}/evaluation/request'
|
|
173
|
-
headers = {
|
|
174
|
-
'Content-Type': 'application/json',
|
|
175
|
-
'x-api-key': config.api_key
|
|
176
|
-
}
|
|
177
|
-
# Use requests to send a synchronous POST request
|
|
178
|
-
response = requests.post(url, headers=headers, data=eval_request.to_json(casing=Casing.SNAKE), verify=False)
|
|
179
|
-
if response.status_code != 200:
|
|
180
|
-
print(f"Failed to send evaluation request. Status code: {response.status_code}. Error: {response.text}")
|
|
181
|
-
return None
|
|
182
|
-
return response.content
|
|
183
|
-
|
|
184
|
-
result = send_request()
|
|
185
|
-
if result is not None:
|
|
186
|
-
eval_result = EvaluateResponse().from_json(result)
|
|
187
|
-
return eval_result
|
|
188
|
-
|
|
189
|
-
@classmethod
|
|
190
|
-
async def send_session_context_update(cls, session_context):
|
|
191
|
-
async def send_context():
|
|
192
|
-
try:
|
|
193
|
-
host = config.maitai_host
|
|
194
|
-
url = f'{host}/context/session'
|
|
195
|
-
headers = {
|
|
196
|
-
'Content-Type': 'application/json',
|
|
197
|
-
'x-api-key': config.api_key
|
|
198
|
-
}
|
|
199
|
-
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
|
|
200
|
-
async with session.put(url, headers=headers, data=json.dumps(session_context)) as response:
|
|
201
|
-
if response.status != 200:
|
|
202
|
-
error_text = await response.text()
|
|
203
|
-
print(
|
|
204
|
-
f"Failed to send session context update. Status code: {response.status}. Error: {error_text}")
|
|
205
|
-
else:
|
|
206
|
-
print(f"Successfully sent session context update. Status code: {response.status}")
|
|
207
|
-
except Exception as e:
|
|
208
|
-
print(f"An error occurred while sending session context update: {e}")
|
|
209
|
-
|
|
210
|
-
await send_context()
|
|
211
|
-
|
|
212
|
-
@classmethod
|
|
213
|
-
async def send_session_context_append(cls, session_context):
|
|
214
|
-
async def send_context():
|
|
215
|
-
try:
|
|
216
|
-
host = config.maitai_host
|
|
217
|
-
url = f'{host}/context/session/append'
|
|
218
|
-
headers = {
|
|
219
|
-
'Content-Type': 'application/json',
|
|
220
|
-
'x-api-key': config.api_key
|
|
221
|
-
}
|
|
222
|
-
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
|
|
223
|
-
async with session.put(url, headers=headers, data=json.dumps(session_context)) as response:
|
|
224
|
-
if response.status != 200:
|
|
225
|
-
error_text = await response.text()
|
|
226
|
-
print(
|
|
227
|
-
f"Failed to send session context for append. Status code: {response.status}. Error: {error_text}")
|
|
228
|
-
else:
|
|
229
|
-
print(f"Successfully sent session context for append. Status code: {response.status}")
|
|
230
|
-
except Exception as e:
|
|
231
|
-
print(f"An error occurred while sending session context for append: {e}")
|
|
232
|
-
|
|
233
|
-
await send_context()
|
|
234
|
-
|
|
235
|
-
@classmethod
|
|
236
|
-
async def send_application_context_update(cls, application_context):
|
|
237
|
-
async def send_context():
|
|
238
|
-
try:
|
|
239
|
-
host = config.maitai_host
|
|
240
|
-
url = f'{host}/context/application'
|
|
241
|
-
headers = {
|
|
242
|
-
'Content-Type': 'application/json',
|
|
243
|
-
'x-api-key': config.api_key
|
|
244
|
-
}
|
|
245
|
-
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
|
|
246
|
-
async with session.put(url, headers=headers, data=json.dumps(application_context)) as response:
|
|
247
|
-
if response.status != 200:
|
|
248
|
-
error_text = await response.text()
|
|
249
|
-
print(
|
|
250
|
-
f"Failed to send application context update. Status code: {response.status}. Error: {error_text}")
|
|
251
|
-
else:
|
|
252
|
-
print(f"Successfully sent application context update. Status code: {response.status}")
|
|
253
|
-
except Exception as e:
|
|
254
|
-
print(f"An error occurred while sending application context update: {e}")
|
|
255
|
-
|
|
256
|
-
await send_context()
|
|
257
|
-
|
|
258
|
-
@classmethod
|
|
259
|
-
async def send_application_context_append(cls, application_context):
|
|
260
|
-
async def send_context():
|
|
261
|
-
try:
|
|
262
|
-
host = config.maitai_host
|
|
263
|
-
url = f'{host}/context/application/append'
|
|
264
|
-
headers = {
|
|
265
|
-
'Content-Type': 'application/json',
|
|
266
|
-
'x-api-key': config.api_key
|
|
267
|
-
}
|
|
268
|
-
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
|
|
269
|
-
async with session.put(url, headers=headers, data=json.dumps(application_context)) as response:
|
|
270
|
-
if response.status != 200:
|
|
271
|
-
error_text = await response.text()
|
|
272
|
-
print(
|
|
273
|
-
f"Failed to send application context for append. Status code: {response.status}. Error: {error_text}")
|
|
274
|
-
else:
|
|
275
|
-
print(f"Successfully sent application context for append. Status code: {response.status}")
|
|
276
|
-
except Exception as e:
|
|
277
|
-
print(f"An error occurred while sending application context for append: {e}")
|
|
278
|
-
|
|
279
|
-
await send_context()
|
|
280
|
-
|
|
281
110
|
@classmethod
|
|
282
111
|
def send_realtime_eval_request(cls, eval_request: EvaluateRequest) -> Iterable[ChatCompletionChunk]:
|
|
283
112
|
def consume_stream():
|
maitai/_inference.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import traceback
|
|
1
2
|
from typing import AsyncIterable, Iterable
|
|
2
3
|
|
|
3
4
|
import aiohttp
|
|
@@ -5,22 +6,21 @@ import requests
|
|
|
5
6
|
from betterproto import Casing
|
|
6
7
|
|
|
7
8
|
from maitai._config import config
|
|
8
|
-
from maitai._maitai_client import
|
|
9
|
+
from maitai._maitai_client import MaitaiClient
|
|
9
10
|
from maitai._types import AsyncChunkQueue, ChunkQueue, EvaluateCallback, QueueIterable
|
|
10
11
|
from maitai_gen.chat import ChatCompletionParams, ChatCompletionRequest
|
|
11
12
|
from maitai_gen.inference import InferenceStreamResponse
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
class Inference(
|
|
15
|
+
class Inference(MaitaiClient):
|
|
15
16
|
|
|
16
17
|
def __init__(self):
|
|
17
18
|
super().__init__()
|
|
18
19
|
|
|
19
20
|
@classmethod
|
|
20
|
-
def infer(cls, session_id, reference_id, action_type, application_ref_name, completion_params: ChatCompletionParams, evaluate_callback: EvaluateCallback = None,
|
|
21
|
+
def infer(cls, session_id, reference_id, action_type, application_ref_name, completion_params: ChatCompletionParams, apply_corrections: bool, evaluation_enabled: bool, evaluate_callback: EvaluateCallback = None,
|
|
21
22
|
timeout=None) -> Iterable[InferenceStreamResponse]:
|
|
22
|
-
|
|
23
|
-
chat_request: ChatCompletionRequest = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, apply_corrections, completion_params)
|
|
23
|
+
chat_request: ChatCompletionRequest = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params)
|
|
24
24
|
if evaluate_callback:
|
|
25
25
|
q = ChunkQueue()
|
|
26
26
|
cls.run_async(cls.send_inference_request_async(chat_request, chunk_queue=q, evaluation_callback=evaluate_callback))
|
|
@@ -29,16 +29,16 @@ class Inference(MaiTaiClient):
|
|
|
29
29
|
return cls.send_inference_request(chat_request)
|
|
30
30
|
|
|
31
31
|
@classmethod
|
|
32
|
-
async def infer_async(cls, session_id, reference_id, action_type, application_ref_name, completion_params: ChatCompletionParams,
|
|
32
|
+
async def infer_async(cls, session_id, reference_id, action_type, application_ref_name, completion_params: ChatCompletionParams, apply_corrections: bool, evaluation_enabled: bool,
|
|
33
|
+
evaluate_callback: EvaluateCallback = None,
|
|
33
34
|
timeout=None) -> AsyncIterable[InferenceStreamResponse]:
|
|
34
|
-
|
|
35
|
-
chat_request: ChatCompletionRequest = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, apply_corrections, completion_params)
|
|
35
|
+
chat_request: ChatCompletionRequest = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params)
|
|
36
36
|
q = AsyncChunkQueue()
|
|
37
37
|
cls.run_async(cls.send_inference_request_async(chat_request, async_chunk_queue=q, evaluation_callback=evaluate_callback))
|
|
38
38
|
return QueueIterable(q, timeout=timeout)
|
|
39
39
|
|
|
40
40
|
@classmethod
|
|
41
|
-
def create_inference_request(cls, application_ref_name, session_id, reference_id, action_type, apply_corrections, completion_params: ChatCompletionParams):
|
|
41
|
+
def create_inference_request(cls, application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params: ChatCompletionParams):
|
|
42
42
|
infer_request: ChatCompletionRequest = ChatCompletionRequest()
|
|
43
43
|
infer_request.application_ref_name = application_ref_name
|
|
44
44
|
infer_request.reference_id = reference_id
|
|
@@ -46,6 +46,7 @@ class Inference(MaiTaiClient):
|
|
|
46
46
|
infer_request.action_type = action_type
|
|
47
47
|
infer_request.apply_corrections = apply_corrections
|
|
48
48
|
infer_request.params = completion_params
|
|
49
|
+
infer_request.evaluation_enabled = evaluation_enabled
|
|
49
50
|
return infer_request
|
|
50
51
|
|
|
51
52
|
@classmethod
|
|
@@ -57,7 +58,6 @@ class Inference(MaiTaiClient):
|
|
|
57
58
|
'Content-Type': 'application/json',
|
|
58
59
|
'x-api-key': config.api_key
|
|
59
60
|
}
|
|
60
|
-
|
|
61
61
|
response = requests.post(url, headers=headers, data=chat_request.to_json(casing=Casing.SNAKE), verify=False, stream=True)
|
|
62
62
|
if response.status_code != 200:
|
|
63
63
|
print(f"Failed to send inference request. Status code: {response.status_code}. Error: {response.text}")
|
|
@@ -93,7 +93,6 @@ class Inference(MaiTaiClient):
|
|
|
93
93
|
if async_chunk_queue:
|
|
94
94
|
await async_chunk_queue.put("done")
|
|
95
95
|
return
|
|
96
|
-
last_item = None
|
|
97
96
|
async for line in response.content:
|
|
98
97
|
if line:
|
|
99
98
|
inference_response: InferenceStreamResponse = InferenceStreamResponse().from_json(line)
|
|
@@ -101,11 +100,12 @@ class Inference(MaiTaiClient):
|
|
|
101
100
|
chunk_queue.put(inference_response)
|
|
102
101
|
if async_chunk_queue:
|
|
103
102
|
await async_chunk_queue.put(inference_response)
|
|
104
|
-
|
|
103
|
+
if inference_response.evaluate_response and evaluation_callback:
|
|
104
|
+
try:
|
|
105
|
+
evaluation_callback(inference_response.evaluate_response)
|
|
106
|
+
except:
|
|
107
|
+
traceback.print_exc()
|
|
105
108
|
if chunk_queue:
|
|
106
109
|
chunk_queue.put("done")
|
|
107
110
|
if async_chunk_queue:
|
|
108
111
|
await async_chunk_queue.put("done")
|
|
109
|
-
if last_item is not None and last_item.evaluate_response:
|
|
110
|
-
if evaluation_callback:
|
|
111
|
-
evaluation_callback(last_item.evaluate_response)
|
maitai/_maitai_client.py
CHANGED
maitai/_openai.py
CHANGED
|
@@ -7,19 +7,19 @@ import openai.types.chat as openai_chat_types
|
|
|
7
7
|
|
|
8
8
|
import maitai
|
|
9
9
|
from maitai._config import config
|
|
10
|
+
from maitai._evaluator import Evaluator
|
|
10
11
|
from maitai._openai_types import Body, Headers, Query
|
|
11
12
|
from maitai._types import EvaluateCallback
|
|
12
|
-
from maitai._utils import convert_open_ai_chat_completion_chunk, convert_openai_chat_completion, get_chat_completion_params,
|
|
13
|
-
set_completion_evaluation_response
|
|
14
|
-
from maitai_common.processes.stream_evaluation_thread import StreamEvaluationThread
|
|
13
|
+
from maitai._utils import convert_open_ai_chat_completion_chunk, convert_openai_chat_completion, get_chat_completion_params, required_args
|
|
15
14
|
from maitai_common.utils.proto_utils import openai_messages_to_proto
|
|
16
|
-
from maitai_gen.chat import ChatCompletionChunk, ChatCompletionResponse, ChatMessage,
|
|
15
|
+
from maitai_gen.chat import ChatCompletionChunk, ChatCompletionResponse, ChatMessage, EvaluationContentType
|
|
16
|
+
from maitai_gen.config import InferenceLocations
|
|
17
17
|
from maitai_gen.inference import InferenceStreamResponse
|
|
18
18
|
|
|
19
19
|
DEFAULT_MAX_RETRIES = 2
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class
|
|
22
|
+
class MaitaiOpenAIClient:
|
|
23
23
|
def __init__(
|
|
24
24
|
self,
|
|
25
25
|
*,
|
|
@@ -63,7 +63,8 @@ class Completions:
|
|
|
63
63
|
client = openai.OpenAI()
|
|
64
64
|
self.client = client
|
|
65
65
|
|
|
66
|
-
@required_args(["session_id", "action_type", "application_ref_name", "messages"
|
|
66
|
+
@required_args(["session_id", "action_type", "application_ref_name", "messages"],
|
|
67
|
+
["session_id", "action_type", "application_ref_name", "messages", "model"],
|
|
67
68
|
["session_id", "action_type", "application_ref_name", "messages", "model", "stream"])
|
|
68
69
|
def create(
|
|
69
70
|
self,
|
|
@@ -74,10 +75,12 @@ class Completions:
|
|
|
74
75
|
action_type: str = None,
|
|
75
76
|
application_ref_name: str = None,
|
|
76
77
|
callback: Optional[EvaluateCallback] = None,
|
|
77
|
-
server_side_inference: bool =
|
|
78
|
+
server_side_inference: bool = None,
|
|
79
|
+
evaluation_enabled: bool = None,
|
|
80
|
+
apply_corrections: bool = None,
|
|
78
81
|
# OpenAI Arguments
|
|
79
82
|
messages: Iterable[openai_chat_types.ChatCompletionMessageParam],
|
|
80
|
-
model: Union[str, openai_types.ChatModel],
|
|
83
|
+
model: Union[str, openai_types.ChatModel, openai.NotGiven] = openai.NOT_GIVEN,
|
|
81
84
|
frequency_penalty: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
82
85
|
function_call: Union[openai_chat_types.completion_create_params.FunctionCall, openai.NotGiven] = openai.NOT_GIVEN,
|
|
83
86
|
functions: Union[Iterable[openai_chat_types.completion_create_params.Function], openai.NotGiven] = openai.NOT_GIVEN,
|
|
@@ -89,7 +92,7 @@ class Completions:
|
|
|
89
92
|
response_format: Union[openai_chat_types.completion_create_params.ResponseFormat, openai.NotGiven] = openai.NOT_GIVEN,
|
|
90
93
|
seed: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
91
94
|
stop: Union[Union[Optional[str], List[str]], openai.NotGiven] = openai.NOT_GIVEN,
|
|
92
|
-
stream: Optional[bool] =
|
|
95
|
+
stream: Union[Optional[bool], openai.NotGiven] = openai.NOT_GIVEN,
|
|
93
96
|
stream_options: Union[Optional[openai_chat_types.ChatCompletionStreamOptionsParam], openai.NotGiven] = openai.NOT_GIVEN,
|
|
94
97
|
temperature: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
95
98
|
tool_choice: Union[openai_chat_types.ChatCompletionToolChoiceOptionParam, openai.NotGiven] = openai.NOT_GIVEN,
|
|
@@ -104,6 +107,33 @@ class Completions:
|
|
|
104
107
|
) -> Union[ChatCompletionResponse, Iterable[ChatCompletionChunk]]:
|
|
105
108
|
if not config.api_key:
|
|
106
109
|
raise ValueError("Maitai API Key has not been set")
|
|
110
|
+
if server_side_inference is False and apply_corrections is True:
|
|
111
|
+
raise ValueError("server_side_inference must be true to apply_corrections")
|
|
112
|
+
if apply_corrections is True and evaluation_enabled is False:
|
|
113
|
+
raise ValueError("evaluations must be enabled to apply_corrections")
|
|
114
|
+
maitai_config = config.get_application_action_config(application_ref_name, action_type)
|
|
115
|
+
if server_side_inference is None:
|
|
116
|
+
server_side_inference = maitai_config.inference_location == InferenceLocations.SERVER
|
|
117
|
+
if evaluation_enabled is None:
|
|
118
|
+
evaluation_enabled = maitai_config.evaluation_enabled
|
|
119
|
+
if apply_corrections is None:
|
|
120
|
+
apply_corrections = maitai_config.apply_corrections
|
|
121
|
+
if model == openai.NOT_GIVEN:
|
|
122
|
+
model = maitai_config.model
|
|
123
|
+
if temperature == openai.NOT_GIVEN:
|
|
124
|
+
temperature = maitai_config.temperature
|
|
125
|
+
if stream == openai.NOT_GIVEN:
|
|
126
|
+
stream = maitai_config.streaming
|
|
127
|
+
if response_format == openai.NOT_GIVEN:
|
|
128
|
+
response_format = {"type": maitai_config.response_format}
|
|
129
|
+
if stop == openai.NOT_GIVEN and maitai_config.stop is not None:
|
|
130
|
+
stop = maitai_config.stop
|
|
131
|
+
if logprobs == openai.NOT_GIVEN:
|
|
132
|
+
logprobs = maitai_config.logprobs
|
|
133
|
+
if max_tokens == openai.NOT_GIVEN and maitai_config.max_tokens is not None:
|
|
134
|
+
max_tokens = maitai_config.max_tokens
|
|
135
|
+
if n == openai.NOT_GIVEN:
|
|
136
|
+
n = maitai_config.n
|
|
107
137
|
if server_side_inference:
|
|
108
138
|
completion_params = get_chat_completion_params(
|
|
109
139
|
messages=messages,
|
|
@@ -129,20 +159,13 @@ class Completions:
|
|
|
129
159
|
response_timeout = None
|
|
130
160
|
if isinstance(timeout, float) or isinstance(timeout, int):
|
|
131
161
|
response_timeout = timeout
|
|
132
|
-
response = maitai.Inference.infer(session_id, reference_id, action_type, application_ref_name, completion_params, callback, timeout=response_timeout)
|
|
162
|
+
response = maitai.Inference.infer(session_id, reference_id, action_type, application_ref_name, completion_params, apply_corrections, evaluation_enabled, callback, timeout=response_timeout)
|
|
133
163
|
if stream:
|
|
134
|
-
return _process_inference_stream(response
|
|
164
|
+
return _process_inference_stream(response)
|
|
135
165
|
# ChatCompletion only
|
|
136
166
|
chat_completion: Optional[ChatCompletionResponse] = None
|
|
137
167
|
for resp in response:
|
|
138
|
-
|
|
139
|
-
return resp.chat_completion_response
|
|
140
|
-
else:
|
|
141
|
-
if resp.chat_completion_response:
|
|
142
|
-
chat_completion = resp.chat_completion_response
|
|
143
|
-
if resp.evaluate_response and chat_completion:
|
|
144
|
-
set_completion_evaluation_response(chat_completion, resp.evaluate_response)
|
|
145
|
-
return chat_completion
|
|
168
|
+
return resp.chat_completion_response
|
|
146
169
|
return chat_completion
|
|
147
170
|
else:
|
|
148
171
|
response = self.client.chat.completions.create(
|
|
@@ -174,23 +197,22 @@ class Completions:
|
|
|
174
197
|
|
|
175
198
|
)
|
|
176
199
|
if stream:
|
|
177
|
-
return _process_openai_stream(session_id, reference_id, action_type, application_ref_name, messages, response, callback)
|
|
200
|
+
return _process_openai_stream(session_id, reference_id, action_type, application_ref_name, messages, response, evaluation_enabled, callback)
|
|
178
201
|
else:
|
|
179
202
|
maitai_completion = convert_openai_chat_completion(response)
|
|
180
203
|
proto_messages = openai_messages_to_proto(messages)
|
|
181
204
|
proto_messages.append(
|
|
182
205
|
ChatMessage(role="assistant", content=maitai_completion.choices[0].message.content))
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
set_completion_evaluation_response(maitai_completion, maitai_eval)
|
|
206
|
+
if evaluation_enabled:
|
|
207
|
+
maitai.Evaluator.evaluate(
|
|
208
|
+
session_id=session_id,
|
|
209
|
+
reference_id=reference_id,
|
|
210
|
+
action_type=action_type,
|
|
211
|
+
content_type=EvaluationContentType.MESSAGE,
|
|
212
|
+
content=proto_messages,
|
|
213
|
+
application_ref_name=application_ref_name,
|
|
214
|
+
callback=callback,
|
|
215
|
+
)
|
|
194
216
|
return maitai_completion
|
|
195
217
|
|
|
196
218
|
|
|
@@ -200,41 +222,34 @@ def _process_openai_stream(session_id: Union[str, int],
|
|
|
200
222
|
application_ref_name: str,
|
|
201
223
|
messages: Iterable[openai_chat_types.ChatCompletionMessageParam],
|
|
202
224
|
stream: openai.Stream[openai_chat_types.ChatCompletionChunk],
|
|
225
|
+
evaluation_enabled: bool,
|
|
203
226
|
callback: Optional[EvaluateCallback] = None) -> Iterable[ChatCompletionChunk]:
|
|
204
227
|
full_body = ""
|
|
205
228
|
proto_messages = openai_messages_to_proto(messages)
|
|
206
|
-
stream_eval_thread = StreamEvaluationThread()
|
|
207
|
-
stream_eval_thread.start()
|
|
208
229
|
for chunk in stream:
|
|
209
|
-
if stream_eval_thread.output:
|
|
210
|
-
result: EvaluateResponse = stream_eval_thread.output
|
|
211
|
-
stream_eval_thread.terminate()
|
|
212
|
-
new_stream = maitai.Evaluator.evaluate_realtime(session_id, reference_id, action_type, EvaluationContentType.PARTIAL, proto_messages, application_ref_name, full_body,
|
|
213
|
-
result.evaluation_results[0].description, result.evaluation_results[0].sentinel_id)
|
|
214
|
-
for new_chunk in new_stream:
|
|
215
|
-
yield new_chunk
|
|
216
|
-
return
|
|
217
230
|
maitai_chunk = convert_open_ai_chat_completion_chunk(chunk)
|
|
218
|
-
|
|
219
|
-
if
|
|
220
|
-
|
|
221
|
-
full_body = new_full_body
|
|
222
|
-
if result_chunk is not None:
|
|
223
|
-
yield result_chunk
|
|
224
|
-
break
|
|
231
|
+
content = maitai_chunk.choices[0].delta.content
|
|
232
|
+
if content is not None:
|
|
233
|
+
full_body += content
|
|
225
234
|
yield maitai_chunk
|
|
226
|
-
|
|
235
|
+
if maitai_chunk.choices[0].finish_reason and evaluation_enabled:
|
|
236
|
+
proto_messages.append(ChatMessage(role="assistant", content=full_body))
|
|
237
|
+
Evaluator.evaluate(
|
|
238
|
+
session_id=session_id,
|
|
239
|
+
reference_id=reference_id,
|
|
240
|
+
action_type=action_type,
|
|
241
|
+
content_type=EvaluationContentType.MESSAGE,
|
|
242
|
+
content=proto_messages,
|
|
243
|
+
application_ref_name=application_ref_name,
|
|
244
|
+
callback=callback
|
|
245
|
+
)
|
|
246
|
+
return
|
|
227
247
|
|
|
228
248
|
|
|
229
|
-
def _process_inference_stream(stream: Iterable[InferenceStreamResponse]
|
|
230
|
-
last_chat_completion_chunk: Optional[ChatCompletionChunk] = None
|
|
249
|
+
def _process_inference_stream(stream: Iterable[InferenceStreamResponse]) -> Iterable[ChatCompletionChunk]:
|
|
231
250
|
for infer_resp in stream:
|
|
232
|
-
chunk =
|
|
251
|
+
chunk = infer_resp.chat_completion_chunk
|
|
233
252
|
if chunk is not None:
|
|
234
|
-
if chunk.choices[0].finish_reason:
|
|
235
|
-
if callback:
|
|
236
|
-
yield chunk
|
|
237
|
-
return
|
|
238
|
-
else:
|
|
239
|
-
last_chat_completion_chunk = chunk
|
|
240
253
|
yield chunk
|
|
254
|
+
if chunk.choices[0].finish_reason:
|
|
255
|
+
return
|
maitai/_openai_async.py
CHANGED
|
@@ -7,19 +7,19 @@ import openai.types.chat as openai_chat_types
|
|
|
7
7
|
|
|
8
8
|
import maitai
|
|
9
9
|
from maitai._config import config
|
|
10
|
+
from maitai._evaluator import Evaluator
|
|
10
11
|
from maitai._openai_types import Body, Headers, Query
|
|
11
12
|
from maitai._types import EvaluateCallback
|
|
12
|
-
from maitai._utils import convert_open_ai_chat_completion_chunk, convert_openai_chat_completion, get_chat_completion_params,
|
|
13
|
-
set_completion_evaluation_response
|
|
14
|
-
from maitai_common.processes.stream_evaluation_thread import StreamEvaluationThread
|
|
13
|
+
from maitai._utils import convert_open_ai_chat_completion_chunk, convert_openai_chat_completion, get_chat_completion_params, required_args
|
|
15
14
|
from maitai_common.utils.proto_utils import openai_messages_to_proto
|
|
16
|
-
from maitai_gen.chat import ChatCompletionChunk, ChatCompletionResponse, ChatMessage,
|
|
15
|
+
from maitai_gen.chat import ChatCompletionChunk, ChatCompletionResponse, ChatMessage, EvaluationContentType
|
|
16
|
+
from maitai_gen.config import InferenceLocations
|
|
17
17
|
from maitai_gen.inference import InferenceStreamResponse
|
|
18
18
|
|
|
19
19
|
DEFAULT_MAX_RETRIES = 2
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class
|
|
22
|
+
class MaitaiAsyncOpenAIClient:
|
|
23
23
|
def __init__(
|
|
24
24
|
self,
|
|
25
25
|
*,
|
|
@@ -65,7 +65,8 @@ class AsyncCompletions:
|
|
|
65
65
|
client = openai.AsyncClient()
|
|
66
66
|
self.client = client
|
|
67
67
|
|
|
68
|
-
@required_args(["session_id", "action_type", "application_ref_name", "messages"
|
|
68
|
+
@required_args(["session_id", "action_type", "application_ref_name", "messages"],
|
|
69
|
+
["session_id", "action_type", "application_ref_name", "messages", "model"],
|
|
69
70
|
["session_id", "action_type", "application_ref_name", "messages", "model", "stream"])
|
|
70
71
|
async def create(
|
|
71
72
|
self,
|
|
@@ -76,10 +77,13 @@ class AsyncCompletions:
|
|
|
76
77
|
action_type: str = None,
|
|
77
78
|
application_ref_name: str = None,
|
|
78
79
|
callback: Optional[EvaluateCallback] = None,
|
|
79
|
-
server_side_inference: bool =
|
|
80
|
+
server_side_inference: bool = None,
|
|
81
|
+
evaluation_enabled: bool = None,
|
|
82
|
+
apply_corrections: bool = None,
|
|
83
|
+
|
|
80
84
|
# OpenAI Arguments
|
|
81
85
|
messages: Iterable[openai_chat_types.ChatCompletionMessageParam],
|
|
82
|
-
model: Union[str, openai_types.ChatModel],
|
|
86
|
+
model: Union[str, openai_types.ChatModel, openai.NotGiven] = openai.NOT_GIVEN,
|
|
83
87
|
frequency_penalty: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
84
88
|
function_call: Union[openai_chat_types.completion_create_params.FunctionCall, openai.NotGiven] = openai.NOT_GIVEN,
|
|
85
89
|
functions: Union[Iterable[openai_chat_types.completion_create_params.Function], openai.NotGiven] = openai.NOT_GIVEN,
|
|
@@ -91,7 +95,7 @@ class AsyncCompletions:
|
|
|
91
95
|
response_format: Union[openai_chat_types.completion_create_params.ResponseFormat, openai.NotGiven] = openai.NOT_GIVEN,
|
|
92
96
|
seed: Union[Optional[int], openai.NotGiven] = openai.NOT_GIVEN,
|
|
93
97
|
stop: Union[Union[Optional[str], List[str]], openai.NotGiven] = openai.NOT_GIVEN,
|
|
94
|
-
stream: Optional[bool] =
|
|
98
|
+
stream: Union[Optional[bool], openai.NotGiven] = openai.NOT_GIVEN,
|
|
95
99
|
stream_options: Union[Optional[openai_chat_types.ChatCompletionStreamOptionsParam], openai.NotGiven] = openai.NOT_GIVEN,
|
|
96
100
|
temperature: Union[Optional[float], openai.NotGiven] = openai.NOT_GIVEN,
|
|
97
101
|
tool_choice: Union[openai_chat_types.ChatCompletionToolChoiceOptionParam, openai.NotGiven] = openai.NOT_GIVEN,
|
|
@@ -106,6 +110,34 @@ class AsyncCompletions:
|
|
|
106
110
|
) -> Union[ChatCompletionResponse, AsyncIterable[ChatCompletionChunk]]:
|
|
107
111
|
if not config.api_key:
|
|
108
112
|
raise ValueError("Maitai API Key has not been set")
|
|
113
|
+
if server_side_inference is False and apply_corrections is True:
|
|
114
|
+
raise ValueError("server_side_inference must be true to apply_corrections")
|
|
115
|
+
if apply_corrections is True and evaluation_enabled is False:
|
|
116
|
+
raise ValueError("evaluations must be enabled to apply_corrections")
|
|
117
|
+
maitai_config = config.get_application_action_config(application_ref_name, action_type)
|
|
118
|
+
if server_side_inference is None:
|
|
119
|
+
server_side_inference = maitai_config.inference_location == InferenceLocations.SERVER
|
|
120
|
+
if evaluation_enabled is None:
|
|
121
|
+
evaluation_enabled = maitai_config.evaluation_enabled
|
|
122
|
+
if apply_corrections is None:
|
|
123
|
+
apply_corrections = maitai_config.apply_corrections
|
|
124
|
+
if model == openai.NOT_GIVEN:
|
|
125
|
+
model = maitai_config.model
|
|
126
|
+
if temperature == openai.NOT_GIVEN:
|
|
127
|
+
temperature = maitai_config.temperature
|
|
128
|
+
if stream == openai.NOT_GIVEN:
|
|
129
|
+
stream = maitai_config.streaming
|
|
130
|
+
if response_format == openai.NOT_GIVEN:
|
|
131
|
+
response_format = {"type": maitai_config.response_format}
|
|
132
|
+
if stop == openai.NOT_GIVEN and maitai_config.stop is not None:
|
|
133
|
+
stop = maitai_config.stop
|
|
134
|
+
if logprobs == openai.NOT_GIVEN:
|
|
135
|
+
logprobs = maitai_config.logprobs
|
|
136
|
+
if max_tokens == openai.NOT_GIVEN and maitai_config.max_tokens is not None:
|
|
137
|
+
max_tokens = maitai_config.max_tokens
|
|
138
|
+
if n == openai.NOT_GIVEN:
|
|
139
|
+
n = maitai_config.n
|
|
140
|
+
|
|
109
141
|
if server_side_inference:
|
|
110
142
|
completion_params = get_chat_completion_params(
|
|
111
143
|
messages=messages,
|
|
@@ -131,20 +163,13 @@ class AsyncCompletions:
|
|
|
131
163
|
response_timeout = None
|
|
132
164
|
if isinstance(timeout, float) or isinstance(timeout, int):
|
|
133
165
|
response_timeout = timeout
|
|
134
|
-
response = await maitai.Inference.infer_async(session_id, reference_id, action_type, application_ref_name, completion_params, callback, timeout=response_timeout)
|
|
166
|
+
response = await maitai.Inference.infer_async(session_id, reference_id, action_type, application_ref_name, completion_params, apply_corrections, evaluation_enabled, callback, timeout=response_timeout)
|
|
135
167
|
if stream:
|
|
136
|
-
return _process_inference_stream_async(response
|
|
168
|
+
return _process_inference_stream_async(response)
|
|
137
169
|
# ChatCompletion only
|
|
138
170
|
chat_completion: Optional[ChatCompletionResponse] = None
|
|
139
171
|
async for resp in response:
|
|
140
|
-
|
|
141
|
-
return resp.chat_completion_response
|
|
142
|
-
else:
|
|
143
|
-
if resp.chat_completion_response:
|
|
144
|
-
chat_completion = resp.chat_completion_response
|
|
145
|
-
if resp.evaluate_response and chat_completion:
|
|
146
|
-
set_completion_evaluation_response(chat_completion, resp.evaluate_response)
|
|
147
|
-
return chat_completion
|
|
172
|
+
return resp.chat_completion_response
|
|
148
173
|
return chat_completion
|
|
149
174
|
else:
|
|
150
175
|
response = await self.client.chat.completions.create(
|
|
@@ -176,23 +201,22 @@ class AsyncCompletions:
|
|
|
176
201
|
|
|
177
202
|
)
|
|
178
203
|
if stream:
|
|
179
|
-
return _process_async_openai_stream(session_id, reference_id, action_type, application_ref_name, messages, response, callback)
|
|
204
|
+
return _process_async_openai_stream(session_id, reference_id, action_type, application_ref_name, messages, response, evaluation_enabled, callback)
|
|
180
205
|
else:
|
|
181
206
|
maitai_completion = convert_openai_chat_completion(response)
|
|
182
207
|
proto_messages = openai_messages_to_proto(messages)
|
|
183
208
|
proto_messages.append(
|
|
184
209
|
ChatMessage(role="assistant", content=maitai_completion.choices[0].message.content))
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
set_completion_evaluation_response(maitai_completion, maitai_eval)
|
|
210
|
+
if evaluation_enabled:
|
|
211
|
+
await maitai.Evaluator.evaluate_async(
|
|
212
|
+
session_id=session_id,
|
|
213
|
+
reference_id=reference_id,
|
|
214
|
+
action_type=action_type,
|
|
215
|
+
content_type=EvaluationContentType.MESSAGE,
|
|
216
|
+
content=proto_messages,
|
|
217
|
+
application_ref_name=application_ref_name,
|
|
218
|
+
callback=callback,
|
|
219
|
+
)
|
|
196
220
|
return maitai_completion
|
|
197
221
|
|
|
198
222
|
|
|
@@ -202,41 +226,34 @@ async def _process_async_openai_stream(session_id: Union[str, int],
|
|
|
202
226
|
application_ref_name: str,
|
|
203
227
|
messages: Iterable[openai_chat_types.ChatCompletionMessageParam],
|
|
204
228
|
stream: openai.AsyncStream[openai_chat_types.ChatCompletionChunk],
|
|
229
|
+
evaluation_enabled: bool,
|
|
205
230
|
callback: Optional[EvaluateCallback] = None) -> AsyncIterable[ChatCompletionChunk]:
|
|
206
231
|
full_body = ""
|
|
207
232
|
proto_messages = openai_messages_to_proto(messages)
|
|
208
|
-
stream_eval_thread = StreamEvaluationThread()
|
|
209
|
-
stream_eval_thread.start()
|
|
210
233
|
async for chunk in stream:
|
|
211
|
-
if stream_eval_thread.output:
|
|
212
|
-
result: EvaluateResponse = stream_eval_thread.output
|
|
213
|
-
stream_eval_thread.terminate()
|
|
214
|
-
new_stream = maitai.Evaluator.evaluate_realtime(session_id, reference_id, action_type, EvaluationContentType.PARTIAL, proto_messages, application_ref_name, full_body,
|
|
215
|
-
result.evaluation_results[0].description, result.evaluation_results[0].sentinel_id)
|
|
216
|
-
for new_chunk in new_stream:
|
|
217
|
-
yield new_chunk
|
|
218
|
-
return
|
|
219
234
|
maitai_chunk = convert_open_ai_chat_completion_chunk(chunk)
|
|
220
|
-
|
|
221
|
-
if
|
|
222
|
-
|
|
223
|
-
full_body = new_full_body
|
|
224
|
-
if result_chunk is not None:
|
|
225
|
-
yield result_chunk
|
|
226
|
-
break
|
|
235
|
+
content = maitai_chunk.choices[0].delta.content
|
|
236
|
+
if content is not None:
|
|
237
|
+
full_body += content
|
|
227
238
|
yield maitai_chunk
|
|
228
|
-
|
|
239
|
+
if maitai_chunk.choices[0].finish_reason and evaluation_enabled:
|
|
240
|
+
proto_messages.append(ChatMessage(role="assistant", content=full_body))
|
|
241
|
+
await Evaluator.evaluate_async(
|
|
242
|
+
session_id=session_id,
|
|
243
|
+
reference_id=reference_id,
|
|
244
|
+
action_type=action_type,
|
|
245
|
+
content_type=EvaluationContentType.MESSAGE,
|
|
246
|
+
content=proto_messages,
|
|
247
|
+
application_ref_name=application_ref_name,
|
|
248
|
+
callback=callback
|
|
249
|
+
)
|
|
250
|
+
return
|
|
229
251
|
|
|
230
252
|
|
|
231
|
-
async def _process_inference_stream_async(stream: AsyncIterable[InferenceStreamResponse]
|
|
232
|
-
last_chat_completion_chunk: Optional[ChatCompletionChunk] = None
|
|
253
|
+
async def _process_inference_stream_async(stream: AsyncIterable[InferenceStreamResponse]) -> AsyncIterable[ChatCompletionChunk]:
|
|
233
254
|
async for infer_resp in stream:
|
|
234
|
-
chunk =
|
|
255
|
+
chunk = infer_resp.chat_completion_chunk
|
|
235
256
|
if chunk is not None:
|
|
236
|
-
if chunk.choices[0].finish_reason:
|
|
237
|
-
if callback:
|
|
238
|
-
yield chunk
|
|
239
|
-
return
|
|
240
|
-
else:
|
|
241
|
-
last_chat_completion_chunk = chunk
|
|
242
257
|
yield chunk
|
|
258
|
+
if chunk.choices[0].finish_reason:
|
|
259
|
+
return
|
maitai/_utils.py
CHANGED
|
@@ -10,8 +10,7 @@ import maitai_gen.chat as chat_types
|
|
|
10
10
|
from maitai._evaluator import Evaluator
|
|
11
11
|
from maitai._types import EvaluateCallback
|
|
12
12
|
from maitai_common.utils.proto_utils import openai_messages_to_proto
|
|
13
|
-
from maitai_gen.chat import ChatCompletionParams,
|
|
14
|
-
from maitai_gen.inference import InferenceStreamResponse
|
|
13
|
+
from maitai_gen.chat import ChatCompletionParams, Function, ResponseFormat, StreamOptions, Tool
|
|
15
14
|
|
|
16
15
|
CallableT = TypeVar("CallableT", bound=Callable[..., Any])
|
|
17
16
|
|
|
@@ -94,15 +93,6 @@ def convert_openai_chat_completion(chat: openai_types.ChatCompletion) -> chat_ty
|
|
|
94
93
|
return chat_types.ChatCompletionResponse().from_dict(chat.to_dict())
|
|
95
94
|
|
|
96
95
|
|
|
97
|
-
def set_completion_evaluation_response(completion: chat_types.ChatCompletionResponse, response: EvaluateResponse):
|
|
98
|
-
completion.evaluate_response = response
|
|
99
|
-
try:
|
|
100
|
-
completion.choices[0].message.content = response.evaluation_results[0].meta["correction_pre"]
|
|
101
|
-
completion.original_choices = [_copy_choice(choice) for choice in completion.choices]
|
|
102
|
-
except:
|
|
103
|
-
pass
|
|
104
|
-
|
|
105
|
-
|
|
106
96
|
def _copy_choice(choice: Union[openai_types.chat_completion.Choice, chat_types.ChatCompletionChoice]) -> chat_types.ChatCompletionChoice:
|
|
107
97
|
message = chat_types.ChatMessage(content=choice.message.content, role=choice.message.role)
|
|
108
98
|
copied_choice = chat_types.ChatCompletionChoice(finish_reason=choice.finish_reason, index=choice.index,
|
|
@@ -110,10 +100,6 @@ def _copy_choice(choice: Union[openai_types.chat_completion.Choice, chat_types.C
|
|
|
110
100
|
return copied_choice
|
|
111
101
|
|
|
112
102
|
|
|
113
|
-
def set_chunk_evaluation_response(chunk: chat_types.ChatCompletionChunk, response: EvaluateResponse):
|
|
114
|
-
chunk.evaluate_response = response
|
|
115
|
-
|
|
116
|
-
|
|
117
103
|
def convert_open_ai_chat_completion_chunk(chunk: openai_types.ChatCompletionChunk) -> chat_types.ChatCompletionChunk:
|
|
118
104
|
return chat_types.ChatCompletionChunk().from_dict(chunk.to_dict())
|
|
119
105
|
|
|
@@ -188,25 +174,6 @@ def get_chat_completion_params(*,
|
|
|
188
174
|
return params
|
|
189
175
|
|
|
190
176
|
|
|
191
|
-
def process_stream_response(infer_resp: InferenceStreamResponse, callback: EvaluateCallback,
|
|
192
|
-
last_chat_completion_chunk: Optional[chat_types.ChatCompletionChunk]) -> Union[chat_types.ChatCompletionChunk, None]:
|
|
193
|
-
if infer_resp.evaluate_response:
|
|
194
|
-
if not callback:
|
|
195
|
-
maitai_chunk = last_chat_completion_chunk
|
|
196
|
-
set_chunk_evaluation_response(maitai_chunk, infer_resp.evaluate_response)
|
|
197
|
-
return maitai_chunk
|
|
198
|
-
|
|
199
|
-
if infer_resp.chat_completion_chunk:
|
|
200
|
-
chunk = infer_resp.chat_completion_chunk
|
|
201
|
-
if chunk.choices[0].finish_reason:
|
|
202
|
-
if callback:
|
|
203
|
-
return chunk
|
|
204
|
-
else:
|
|
205
|
-
return chunk
|
|
206
|
-
return chunk
|
|
207
|
-
return None
|
|
208
|
-
|
|
209
|
-
|
|
210
177
|
def process_chunk(session_id: Union[str, int],
|
|
211
178
|
reference_id: Union[str, int, None],
|
|
212
179
|
action_type: str,
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from maitai_gen.config import Config, InferenceLocations
|
|
2
|
+
|
|
3
|
+
# TODO consider finding a source of truth where we don't need to deploy everytime a new model comes out
|
|
4
|
+
MODELS = {
|
|
5
|
+
"llama3-70b-8192": "groq",
|
|
6
|
+
"gpt-4o": "openai",
|
|
7
|
+
"gpt-4o-2024-05-13": "openai",
|
|
8
|
+
"gpt-4-turbo": "openai",
|
|
9
|
+
"gpt-4-turbo-2024-04-09": "openai",
|
|
10
|
+
"gpt-4-0125-preview": "openai",
|
|
11
|
+
"gpt-4-turbo-preview": "openai",
|
|
12
|
+
"gpt-4-1106-preview": "openai",
|
|
13
|
+
"gpt-4-vision-preview": "openai",
|
|
14
|
+
"gpt-4": "openai",
|
|
15
|
+
"gpt-4-0314": "openai",
|
|
16
|
+
"gpt-4-0613": "openai",
|
|
17
|
+
"gpt-4-32k": "openai",
|
|
18
|
+
"gpt-4-32k-0314": "openai",
|
|
19
|
+
"gpt-4-32k-0613": "openai",
|
|
20
|
+
"gpt-3.5-turbo": "openai",
|
|
21
|
+
"gpt-3.5-turbo-16k": "openai",
|
|
22
|
+
"gpt-3.5-turbo-0301": "openai",
|
|
23
|
+
"gpt-3.5-turbo-0613": "openai",
|
|
24
|
+
"gpt-3.5-turbo-1106": "openai",
|
|
25
|
+
"gpt-3.5-turbo-0125": "openai",
|
|
26
|
+
"gpt-3.5-turbo-16k-0613": "openai",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def get_default_config() -> Config:
|
|
31
|
+
return Config(
|
|
32
|
+
inference_location=InferenceLocations.SERVER,
|
|
33
|
+
evaluation_enabled=True,
|
|
34
|
+
apply_corrections=True,
|
|
35
|
+
model='gpt-4o',
|
|
36
|
+
temperature=0.4,
|
|
37
|
+
streaming=False,
|
|
38
|
+
response_format="text",
|
|
39
|
+
stop=None,
|
|
40
|
+
logprobs=False,
|
|
41
|
+
max_tokens=None,
|
|
42
|
+
n=1,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def get_model_provider(model_name: str):
|
|
47
|
+
return MODELS[model_name]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def get_available_models():
|
|
51
|
+
return {"models": list(MODELS.keys())}
|
|
@@ -4,17 +4,24 @@
|
|
|
4
4
|
# This file has been @generated
|
|
5
5
|
|
|
6
6
|
from dataclasses import dataclass
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import (
|
|
8
|
+
Dict,
|
|
9
|
+
List,
|
|
10
|
+
)
|
|
8
11
|
|
|
9
12
|
import betterproto
|
|
10
13
|
|
|
14
|
+
from .. import config as _config__
|
|
15
|
+
|
|
11
16
|
|
|
12
17
|
@dataclass(eq=False, repr=False)
|
|
13
18
|
class ApplicationObjective(betterproto.Message):
|
|
14
19
|
id: int = betterproto.int64_field(1)
|
|
15
20
|
date_created: int = betterproto.int64_field(2)
|
|
16
21
|
application_id: int = betterproto.int64_field(3)
|
|
17
|
-
objective_body: str = betterproto.
|
|
22
|
+
objective_body: Dict[str, str] = betterproto.map_field(
|
|
23
|
+
4, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
|
24
|
+
)
|
|
18
25
|
|
|
19
26
|
|
|
20
27
|
@dataclass(eq=False, repr=False)
|
|
@@ -37,3 +44,13 @@ class Application(betterproto.Message):
|
|
|
37
44
|
meta: Dict[str, str] = betterproto.map_field(
|
|
38
45
|
8, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
|
39
46
|
)
|
|
47
|
+
action_types: List["ApplicationAction"] = betterproto.message_field(9)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(eq=False, repr=False)
|
|
51
|
+
class ApplicationAction(betterproto.Message):
|
|
52
|
+
id: int = betterproto.int64_field(1)
|
|
53
|
+
action_type: str = betterproto.string_field(2)
|
|
54
|
+
date_created: int = betterproto.int64_field(3)
|
|
55
|
+
application_id: int = betterproto.int64_field(4)
|
|
56
|
+
meta: "_config__.Config" = betterproto.message_field(5)
|
maitai_gen/chat/__init__.py
CHANGED
|
@@ -43,6 +43,7 @@ class ChatCompletionRequest(betterproto.Message):
|
|
|
43
43
|
id: int = betterproto.int64_field(8)
|
|
44
44
|
date_created: int = betterproto.int64_field(9)
|
|
45
45
|
request_id: str = betterproto.string_field(10)
|
|
46
|
+
evaluation_enabled: bool = betterproto.bool_field(11)
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
@dataclass(eq=False, repr=False)
|
|
@@ -54,7 +55,7 @@ class ChatCompletionParams(betterproto.Message):
|
|
|
54
55
|
temperature: float = betterproto.double_field(5)
|
|
55
56
|
top_p: float = betterproto.double_field(6)
|
|
56
57
|
stop: str = betterproto.string_field(7)
|
|
57
|
-
logprobs:
|
|
58
|
+
logprobs: bool = betterproto.bool_field(8)
|
|
58
59
|
top_logprobs: int = betterproto.int32_field(9)
|
|
59
60
|
n: int = betterproto.int32_field(10)
|
|
60
61
|
seed: int = betterproto.int32_field(11)
|
|
@@ -198,7 +199,9 @@ class EvaluateRequest(betterproto.Message):
|
|
|
198
199
|
reference_id: str = betterproto.string_field(6)
|
|
199
200
|
action_type: str = betterproto.string_field(7)
|
|
200
201
|
evaluation_content_type: "EvaluationContentType" = betterproto.enum_field(8)
|
|
201
|
-
eval_results_set: "EvaluateResponse" = betterproto.message_field(
|
|
202
|
+
eval_results_set: Optional["EvaluateResponse"] = betterproto.message_field(
|
|
203
|
+
10, optional=True, group="_eval_results_set"
|
|
204
|
+
)
|
|
202
205
|
company_id: int = betterproto.int64_field(11)
|
|
203
206
|
evaluation_context: str = betterproto.string_field(13)
|
|
204
207
|
text_content: str = betterproto.string_field(9)
|
|
@@ -231,7 +234,6 @@ class EvaluateResponse(betterproto.Message):
|
|
|
231
234
|
request_id: int = betterproto.int64_field(5)
|
|
232
235
|
evaluation_results: List["EvaluateResult"] = betterproto.message_field(6)
|
|
233
236
|
evaluation_request_id: str = betterproto.string_field(7)
|
|
234
|
-
evaluation_request: "EvaluateRequest" = betterproto.message_field(8)
|
|
235
237
|
|
|
236
238
|
|
|
237
239
|
class EvaluationServiceStub(betterproto.ServiceStub):
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# sources: config.proto
|
|
3
|
+
# plugin: python-betterproto
|
|
4
|
+
# This file has been @generated
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
import betterproto
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class InferenceLocations(betterproto.Enum):
|
|
13
|
+
CLIENT = 0
|
|
14
|
+
SERVER = 1
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@dataclass(eq=False, repr=False)
|
|
18
|
+
class Config(betterproto.Message):
|
|
19
|
+
inference_location: "InferenceLocations" = betterproto.enum_field(1)
|
|
20
|
+
evaluation_enabled: bool = betterproto.bool_field(2)
|
|
21
|
+
apply_corrections: bool = betterproto.bool_field(3)
|
|
22
|
+
model: str = betterproto.string_field(4)
|
|
23
|
+
temperature: float = betterproto.float_field(5)
|
|
24
|
+
streaming: bool = betterproto.bool_field(6)
|
|
25
|
+
response_format: str = betterproto.string_field(7)
|
|
26
|
+
stop: Optional[str] = betterproto.string_field(8, optional=True, group="_stop")
|
|
27
|
+
logprobs: bool = betterproto.bool_field(9)
|
|
28
|
+
max_tokens: Optional[int] = betterproto.int64_field(
|
|
29
|
+
10, optional=True, group="_max_tokens"
|
|
30
|
+
)
|
|
31
|
+
n: int = betterproto.int64_field(11)
|
maitai_gen/sandbox/__init__.py
CHANGED
|
@@ -7,6 +7,7 @@ from dataclasses import dataclass
|
|
|
7
7
|
from typing import (
|
|
8
8
|
Dict,
|
|
9
9
|
List,
|
|
10
|
+
Optional,
|
|
10
11
|
)
|
|
11
12
|
|
|
12
13
|
import betterproto
|
|
@@ -14,8 +15,10 @@ import betterproto
|
|
|
14
15
|
|
|
15
16
|
@dataclass(eq=False, repr=False)
|
|
16
17
|
class SandboxApplication(betterproto.Message):
|
|
17
|
-
id: int = betterproto.int64_field(1)
|
|
18
|
-
company_id: int = betterproto.int64_field(
|
|
18
|
+
id: Optional[int] = betterproto.int64_field(1, optional=True, group="_id")
|
|
19
|
+
company_id: Optional[int] = betterproto.int64_field(
|
|
20
|
+
2, optional=True, group="_company_id"
|
|
21
|
+
)
|
|
19
22
|
sandbox_application_name: str = betterproto.string_field(3)
|
|
20
23
|
date_created: int = betterproto.int64_field(4)
|
|
21
24
|
sandbox_application_prompt: str = betterproto.string_field(5)
|
|
@@ -33,7 +36,7 @@ class SandboxSession(betterproto.Message):
|
|
|
33
36
|
|
|
34
37
|
@dataclass(eq=False, repr=False)
|
|
35
38
|
class SandboxMessage(betterproto.Message):
|
|
36
|
-
id: int = betterproto.int64_field(1)
|
|
39
|
+
id: Optional[int] = betterproto.int64_field(1, optional=True, group="_id")
|
|
37
40
|
sandbox_session_id: int = betterproto.int64_field(2)
|
|
38
41
|
date_created: int = betterproto.int64_field(3)
|
|
39
42
|
sender: str = betterproto.string_field(4)
|
maitai_gen/sentinel/__init__.py
CHANGED
|
@@ -12,6 +12,13 @@ from typing import (
|
|
|
12
12
|
import betterproto
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
class SeverityLevel(betterproto.Enum):
|
|
16
|
+
INFO = 0
|
|
17
|
+
WARN = 1
|
|
18
|
+
ERROR = 2
|
|
19
|
+
FATAL = 3
|
|
20
|
+
|
|
21
|
+
|
|
15
22
|
@dataclass(eq=False, repr=False)
|
|
16
23
|
class Sentinel(betterproto.Message):
|
|
17
24
|
id: int = betterproto.int64_field(1)
|
maitai_gen/session/__init__.py
CHANGED
|
@@ -13,7 +13,7 @@ from .. import chat as _chat__
|
|
|
13
13
|
|
|
14
14
|
@dataclass(eq=False, repr=False)
|
|
15
15
|
class Session(betterproto.Message):
|
|
16
|
-
session_id:
|
|
16
|
+
session_id: str = betterproto.string_field(1)
|
|
17
17
|
date_created: int = betterproto.int64_field(2)
|
|
18
18
|
application_id: int = betterproto.int64_field(3)
|
|
19
19
|
eval_requests: List["_chat__.EvaluateRequest"] = betterproto.message_field(4)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
maitai/__init__.py,sha256=zPSSwcBFSEhvP9roNjAhfih0h8x_L9lr9DhXpebS2SM,646
|
|
2
|
+
maitai/_azure.py,sha256=ZsaUSZ8JJyyh8axhexuEGWZ7_-QBaUgS8FT8l6gJ9WU,8561
|
|
3
|
+
maitai/_config.py,sha256=y5c1XooRsbcFXK1JD3JQqu7hNKcs1B8P5m_JkAGbjbU,3234
|
|
4
|
+
maitai/_config_listener_thread.py,sha256=Wg8dh5K8ubmZMZJ3RWdtenGCFnhR0B5gzpqhhnMy6kM,495
|
|
5
|
+
maitai/_evaluator.py,sha256=nLk78N5m0m3rLC4InZrU1IOTrDYqZ2JSaWGCuHwnm3Y,6434
|
|
6
|
+
maitai/_inference.py,sha256=m8985sfhpKsG1nNPos9YOaAyztcCjTimCJOjKZtq64A,5901
|
|
7
|
+
maitai/_maitai_client.py,sha256=-1OBiErpy1F8asf4hdEpuNkwD4lmkDEIes8Lxh5YQy0,1135
|
|
8
|
+
maitai/_openai.py,sha256=Dwlj-A7AhPAbkKKsxfpEK7J1DgnBvKzx_HqsRQUVvU0,12075
|
|
9
|
+
maitai/_openai_async.py,sha256=QHnPIEYYWBvF8l4x1K0TES3aGKQNBmWMLAA62sw-29U,12345
|
|
10
|
+
maitai/_openai_types.py,sha256=8OrDnYca0PSU4ICYeB0DGkVIV-sAh89_zRcJPu8h_i0,236
|
|
11
|
+
maitai/_types.py,sha256=dOn2Sn1dojHHbwbJ_954cUb2ucD_HyjxnZz7Mnn0q_c,2324
|
|
12
|
+
maitai/_utils.py,sha256=oWfEnHUXHI-VmgZ0bp2D6B5nVEZzg01lsSOUE81ljsI,8898
|
|
13
|
+
maitai_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
maitai_common/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
maitai_common/config/config_service.py,sha256=LIsRqkz-1SrOXKZYIZRqrGfmPXeZQABAdsaB2rbJNAs,1416
|
|
16
|
+
maitai_common/processes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
maitai_common/processes/io_thread.py,sha256=Ab4P1XtfL_7vvksC7zRVGLBBsiDX6cyweZNYHqcLJ14,2057
|
|
18
|
+
maitai_common/processes/stream_evaluation_thread.py,sha256=UFUfUWsQOUZhvIthVcL5BW_bgxKvIS8Nk9C1reMsfHs,894
|
|
19
|
+
maitai_common/processes/websocket_listener_thread.py,sha256=gJg838HnG7QGki0CtNM1m86bQWBgtvL1rnCGrCRStGQ,3392
|
|
20
|
+
maitai_common/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
+
maitai_common/utils/proto_utils.py,sha256=MhJx_exWOIrroS13UDvmSon_AAJ0O6kbJ_5QApJBtWI,407
|
|
22
|
+
maitai_gen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
maitai_gen/application/__init__.py,sha256=zBMyNf1XelayUHCiZmtET8tOGcZRYObM4FB_f5ae08A,1903
|
|
24
|
+
maitai_gen/chat/__init__.py,sha256=QpmrZh0vXqpoS-EN6B0AMG5oBizZt__lIveJ3qqHRiI,11445
|
|
25
|
+
maitai_gen/company/__init__.py,sha256=AuGIsQJzcxnkZZl5-4wEr1zWeI4d4fMXrASBu-OuXG0,641
|
|
26
|
+
maitai_gen/config/__init__.py,sha256=_osjC7KbcXcVsgpSSWcz2z9EnvT9tV4V3YMVRyG2oEM,1041
|
|
27
|
+
maitai_gen/inference/__init__.py,sha256=pn77lTsfX9JlEwEFTEVKFAdsbnmXS_o0jzYn20SIL1k,600
|
|
28
|
+
maitai_gen/notification/__init__.py,sha256=2WaCP-EwmiPDkneJyGJnB1fpgriukmjHH2ZPgH-1XK0,1198
|
|
29
|
+
maitai_gen/sandbox/__init__.py,sha256=enYj1gknTYnJtFAHnrsPjwKnJgFSCqsmn5cdECVqNRI,1610
|
|
30
|
+
maitai_gen/sentinel/__init__.py,sha256=1aTuX3iyrye_T_xbI3iSCaJKaS5mWcmylVOMVcb7biI,1613
|
|
31
|
+
maitai_gen/session/__init__.py,sha256=NJnCtYfuIesxyLpY9sYtnHS_kn4gI1mO1Dqz0Ds93tQ,887
|
|
32
|
+
maitai_python-1.0.6.dist-info/METADATA,sha256=XkesCgnxcNQf3rGI7d0HoRFnywqUPj5AvalObZvtS28,1719
|
|
33
|
+
maitai_python-1.0.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
34
|
+
maitai_python-1.0.6.dist-info/top_level.txt,sha256=-5U1krxnwlqB-AY7nEe29ZcNvwByNc-SnBe-mph-QjI,32
|
|
35
|
+
maitai_python-1.0.6.dist-info/RECORD,,
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
maitai/__init__.py,sha256=qgXSDt3FJPIY9p3cjqSl4JxZrktShYbKj0-094mEijo,646
|
|
2
|
-
maitai/_azure.py,sha256=K8pljZL5qU2YtffJQbCvrhmSqa-7jc8pNB-CQUMMHJw,8561
|
|
3
|
-
maitai/_config.py,sha256=vIEc57aNF7FsZnfFPkrm3qN_tPpRCyoLaI4-ECjf4F0,2249
|
|
4
|
-
maitai/_config_listener_thread.py,sha256=Wg8dh5K8ubmZMZJ3RWdtenGCFnhR0B5gzpqhhnMy6kM,495
|
|
5
|
-
maitai/_evaluator.py,sha256=X7ZByQqZtnCgPf1NpiX0UayOiziwqNwgY1-hMlKNQFc,14793
|
|
6
|
-
maitai/_inference.py,sha256=tIMHm5k0tgJNjMFpwb7SbzuUxpsERUceCPLRMbaZM8E,5720
|
|
7
|
-
maitai/_maitai_client.py,sha256=s-OkiBAhDND2DpcUqvnfXiv_VAfnHk5FFwThJVbyz-w,1135
|
|
8
|
-
maitai/_openai.py,sha256=y0TZH25WEo_ktuil2xk4e6EOTL4Sr1_0Go236rBVTeA,11579
|
|
9
|
-
maitai/_openai_async.py,sha256=HndCFnPxKBP1dlwAZoiJOHcm2KpZDbTDxdtcDS4WSrQ,11823
|
|
10
|
-
maitai/_openai_types.py,sha256=8OrDnYca0PSU4ICYeB0DGkVIV-sAh89_zRcJPu8h_i0,236
|
|
11
|
-
maitai/_types.py,sha256=dOn2Sn1dojHHbwbJ_954cUb2ucD_HyjxnZz7Mnn0q_c,2324
|
|
12
|
-
maitai/_utils.py,sha256=0GY2Um9BrgE7CL5HFMpyK7sztZqh1oiZ9tO3Sv1ZGJI,10254
|
|
13
|
-
maitai_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
maitai_common/processes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
maitai_common/processes/io_thread.py,sha256=Ab4P1XtfL_7vvksC7zRVGLBBsiDX6cyweZNYHqcLJ14,2057
|
|
16
|
-
maitai_common/processes/stream_evaluation_thread.py,sha256=UFUfUWsQOUZhvIthVcL5BW_bgxKvIS8Nk9C1reMsfHs,894
|
|
17
|
-
maitai_common/processes/websocket_listener_thread.py,sha256=gJg838HnG7QGki0CtNM1m86bQWBgtvL1rnCGrCRStGQ,3392
|
|
18
|
-
maitai_common/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
maitai_common/utils/proto_utils.py,sha256=MhJx_exWOIrroS13UDvmSon_AAJ0O6kbJ_5QApJBtWI,407
|
|
20
|
-
maitai_gen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
maitai_gen/application/__init__.py,sha256=VLSzeOJinN_lJTDQT6pc52vauQF-GN3DB4QWZckC1XE,1364
|
|
22
|
-
maitai_gen/chat/__init__.py,sha256=tz_86t_sK_VFWNQVxP11HCeVAtqtReBXfShqOSy0dgw,11403
|
|
23
|
-
maitai_gen/company/__init__.py,sha256=AuGIsQJzcxnkZZl5-4wEr1zWeI4d4fMXrASBu-OuXG0,641
|
|
24
|
-
maitai_gen/inference/__init__.py,sha256=pn77lTsfX9JlEwEFTEVKFAdsbnmXS_o0jzYn20SIL1k,600
|
|
25
|
-
maitai_gen/notification/__init__.py,sha256=2WaCP-EwmiPDkneJyGJnB1fpgriukmjHH2ZPgH-1XK0,1198
|
|
26
|
-
maitai_gen/sandbox/__init__.py,sha256=fX4BSSo_Qbkh4jhk56E9r5SxO44XmwGh4O3OZCAcKtI,1460
|
|
27
|
-
maitai_gen/sentinel/__init__.py,sha256=hWwzr0izFZ1qS6zhWo2ZuPS5bBCeLjxBcpamF3Xmbho,1518
|
|
28
|
-
maitai_gen/session/__init__.py,sha256=riq0bcNozstLBCkAUmcNAj6RyX7gP5IIFcBO6CLSwqA,886
|
|
29
|
-
maitai_python-1.0.4.dist-info/METADATA,sha256=-frOYTpZT-0mf6U-4onQhq61oBJF7LTcd7JZV6KOZJQ,1719
|
|
30
|
-
maitai_python-1.0.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
31
|
-
maitai_python-1.0.4.dist-info/top_level.txt,sha256=-5U1krxnwlqB-AY7nEe29ZcNvwByNc-SnBe-mph-QjI,32
|
|
32
|
-
maitai_python-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|