maitai-python 1.0.19__tar.gz → 1.0.21__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.0.19 → maitai_python-1.0.21}/PKG-INFO +1 -1
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_config.py +2 -2
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_evaluator.py +11 -10
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_inference.py +5 -5
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_maitai_client.py +2 -1
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_openai.py +12 -2
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_openai_async.py +12 -2
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/config/config_service.py +24 -3
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/version.py +1 -1
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/application/__init__.py +3 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/chat/__init__.py +50 -7
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/config/__init__.py +15 -1
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/session/__init__.py +5 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_python.egg-info/PKG-INFO +1 -1
- {maitai_python-1.0.19 → maitai_python-1.0.21}/README.md +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_azure.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_config_listener_thread.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_openai_types.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai/_utils.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/config/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/processes/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/processes/io_thread.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/processes/websocket_listener_thread.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/utils/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/utils/proto_utils.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_common/utils/types.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/company/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/inference/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/notification/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/sandbox/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_gen/sentinel/__init__.py +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_python.egg-info/SOURCES.txt +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_python.egg-info/dependency_links.txt +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_python.egg-info/requires.txt +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/maitai_python.egg-info/top_level.txt +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/setup.cfg +0 -0
- {maitai_python-1.0.19 → maitai_python-1.0.21}/setup.py +0 -0
|
@@ -65,7 +65,7 @@ class Config:
|
|
|
65
65
|
'x-client-version': version,
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
response = requests.get(url, headers=headers
|
|
68
|
+
response = requests.get(url, headers=headers)
|
|
69
69
|
if response.status_code != 200:
|
|
70
70
|
print(f"Failed to initialize API client. Status code: {response.status_code}. Error: {response.text}")
|
|
71
71
|
return
|
|
@@ -81,7 +81,7 @@ class Config:
|
|
|
81
81
|
'x-client-version': version,
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
response = requests.get(url, headers=headers
|
|
84
|
+
response = requests.get(url, headers=headers)
|
|
85
85
|
if response.status_code != 200:
|
|
86
86
|
print(f"Failed to initialize API client. Status code: {response.status_code}. Error: {response.text}")
|
|
87
87
|
return
|
|
@@ -9,8 +9,8 @@ from betterproto import Casing
|
|
|
9
9
|
from maitai._config import config
|
|
10
10
|
from maitai._maitai_client import MaitaiClient
|
|
11
11
|
from maitai._utils import chat_completion_chunk_to_response
|
|
12
|
-
from maitai_common.version import version
|
|
13
12
|
from maitai_common.utils.types import EvaluateCallback
|
|
13
|
+
from maitai_common.version import version
|
|
14
14
|
from maitai_gen.chat import ChatCompletionChunk, ChatCompletionParams, ChatCompletionResponse, EvaluateRequest, EvaluateResponse, EvaluationContentType
|
|
15
15
|
|
|
16
16
|
|
|
@@ -39,7 +39,7 @@ class Evaluator(MaitaiClient):
|
|
|
39
39
|
raise Exception('application_id or application_ref_name must be provided')
|
|
40
40
|
eval_request: EvaluateRequest = cls.create_eval_request(application_id, application_ref_name, session_id, reference_id, action_type, content_type, content)
|
|
41
41
|
if completion_params is not None:
|
|
42
|
-
eval_request.chat_completion_request = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, False, True, completion_params)
|
|
42
|
+
eval_request.chat_completion_request = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, False, True, completion_params, callback)
|
|
43
43
|
if chat_completion_chunk is not None:
|
|
44
44
|
chat_completion_response = chat_completion_chunk_to_response(chat_completion_chunk, content)
|
|
45
45
|
eval_request.chat_completion_response = chat_completion_response
|
|
@@ -57,7 +57,7 @@ class Evaluator(MaitaiClient):
|
|
|
57
57
|
raise Exception('application_id or application_ref_name must be provided')
|
|
58
58
|
eval_request: EvaluateRequest = cls.create_eval_request(application_id, application_ref_name, session_id, reference_id, action_type, content_type, content, partial=partial)
|
|
59
59
|
if completion_params is not None:
|
|
60
|
-
eval_request.chat_completion_request = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, False, True, completion_params)
|
|
60
|
+
eval_request.chat_completion_request = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, False, True, completion_params, callback)
|
|
61
61
|
if chat_completion_chunk is not None:
|
|
62
62
|
chat_completion_response = chat_completion_chunk_to_response(chat_completion_chunk, content)
|
|
63
63
|
eval_request.chat_completion_response = chat_completion_response
|
|
@@ -65,11 +65,11 @@ class Evaluator(MaitaiClient):
|
|
|
65
65
|
cls.run_async(cls.send_evaluation_request_async(eval_request, callback))
|
|
66
66
|
|
|
67
67
|
@classmethod
|
|
68
|
-
def
|
|
68
|
+
def stream_correction(cls, session_id, reference_id, action_type, content_type, content, application_ref_name, partial, fault_description, sentinel_id):
|
|
69
69
|
eval_request: EvaluateRequest = cls.create_eval_request(None, application_ref_name, session_id, reference_id, action_type, content_type, content, partial=partial,
|
|
70
70
|
fault_description=fault_description)
|
|
71
71
|
eval_request.sentinel_id = sentinel_id
|
|
72
|
-
return cls.
|
|
72
|
+
return cls.send_stream_correction_request(eval_request)
|
|
73
73
|
|
|
74
74
|
@classmethod
|
|
75
75
|
def create_eval_request(cls, application_id, application_ref_name, session_id, reference_id, action_type,
|
|
@@ -97,8 +97,9 @@ class Evaluator(MaitaiClient):
|
|
|
97
97
|
@classmethod
|
|
98
98
|
async def send_evaluation_request_async(cls, eval_request: EvaluateRequest, callback: EvaluateCallback = None):
|
|
99
99
|
async def send_request():
|
|
100
|
+
path = "request" if callback else "submit"
|
|
100
101
|
host = config.maitai_host
|
|
101
|
-
url = f'{host}/evaluation/
|
|
102
|
+
url = f'{host}/evaluation/{path}'
|
|
102
103
|
headers = {
|
|
103
104
|
'Content-Type': 'application/json',
|
|
104
105
|
'x-api-key': config.api_key,
|
|
@@ -125,19 +126,19 @@ class Evaluator(MaitaiClient):
|
|
|
125
126
|
return eval_result
|
|
126
127
|
|
|
127
128
|
@classmethod
|
|
128
|
-
def
|
|
129
|
+
def send_stream_correction_request(cls, eval_request: EvaluateRequest) -> Iterable[ChatCompletionChunk]:
|
|
129
130
|
def consume_stream():
|
|
130
131
|
host = config.maitai_host
|
|
131
|
-
url = f'{host}/evaluation/
|
|
132
|
+
url = f'{host}/evaluation/stream_correction'
|
|
132
133
|
headers = {
|
|
133
134
|
'Content-Type': 'application/json',
|
|
134
135
|
'x-api-key': config.api_key,
|
|
135
136
|
'x-client-version': version,
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
response = requests.post(url, headers=headers, data=eval_request.to_json(casing=Casing.SNAKE),
|
|
139
|
+
response = requests.post(url, headers=headers, data=eval_request.to_json(casing=Casing.SNAKE), stream=True)
|
|
139
140
|
if response.status_code != 200:
|
|
140
|
-
print(f"Failed to send
|
|
141
|
+
print(f"Failed to send stream correction request. Status code: {response.status_code}. Error: {response.text}")
|
|
141
142
|
return
|
|
142
143
|
try:
|
|
143
144
|
for line in response.iter_lines():
|
|
@@ -8,8 +8,8 @@ from betterproto import Casing
|
|
|
8
8
|
from maitai._config import config
|
|
9
9
|
from maitai._maitai_client import MaitaiClient
|
|
10
10
|
from maitai._utils import chat_completion_chunk_to_response
|
|
11
|
-
from maitai_common.version import version
|
|
12
11
|
from maitai_common.utils.types import AsyncChunkQueue, ChunkQueue, EvaluateCallback, QueueIterable
|
|
12
|
+
from maitai_common.version import version
|
|
13
13
|
from maitai_gen.chat import ChatCompletionChunk, ChatCompletionParams, ChatCompletionRequest, ChatCompletionResponse, ChatStorageRequest
|
|
14
14
|
from maitai_gen.inference import InferenceStreamResponse
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ class Inference(MaitaiClient):
|
|
|
27
27
|
@classmethod
|
|
28
28
|
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,
|
|
29
29
|
timeout=None) -> Iterable[InferenceStreamResponse]:
|
|
30
|
-
chat_request: ChatCompletionRequest = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params)
|
|
30
|
+
chat_request: ChatCompletionRequest = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params, evaluate_callback)
|
|
31
31
|
if evaluate_callback:
|
|
32
32
|
q = ChunkQueue()
|
|
33
33
|
cls.run_async(cls.send_inference_request_async(chat_request, chunk_queue=q, evaluation_callback=evaluate_callback))
|
|
@@ -39,7 +39,7 @@ class Inference(MaitaiClient):
|
|
|
39
39
|
async def infer_async(cls, session_id, reference_id, action_type, application_ref_name, completion_params: ChatCompletionParams, apply_corrections: bool, evaluation_enabled: bool,
|
|
40
40
|
evaluate_callback: EvaluateCallback = None,
|
|
41
41
|
timeout=None) -> AsyncIterable[InferenceStreamResponse]:
|
|
42
|
-
chat_request: ChatCompletionRequest = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params)
|
|
42
|
+
chat_request: ChatCompletionRequest = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params, evaluate_callback)
|
|
43
43
|
q = AsyncChunkQueue()
|
|
44
44
|
cls.run_async(cls.send_inference_request_async(chat_request, async_chunk_queue=q, evaluation_callback=evaluate_callback))
|
|
45
45
|
return QueueIterable(q, timeout=timeout)
|
|
@@ -47,7 +47,7 @@ class Inference(MaitaiClient):
|
|
|
47
47
|
@classmethod
|
|
48
48
|
def create_chat_storage_request(cls, session_id, reference_id, action_type, application_ref_name, completion_params: ChatCompletionParams, chat_completion_response: Optional[ChatCompletionResponse],
|
|
49
49
|
final_chunk: Optional[ChatCompletionChunk], content: str):
|
|
50
|
-
inference_request = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, False, False, completion_params)
|
|
50
|
+
inference_request = cls.create_inference_request(application_ref_name, session_id, reference_id, action_type, False, False, completion_params, None)
|
|
51
51
|
if final_chunk:
|
|
52
52
|
chat_completion_response = chat_completion_chunk_to_response(final_chunk, content)
|
|
53
53
|
|
|
@@ -69,7 +69,7 @@ class Inference(MaitaiClient):
|
|
|
69
69
|
'x-api-key': config.api_key,
|
|
70
70
|
'x-client-version': version,
|
|
71
71
|
}
|
|
72
|
-
response = requests.post(url, headers=headers, data=chat_request.to_json(casing=Casing.SNAKE),
|
|
72
|
+
response = requests.post(url, headers=headers, data=chat_request.to_json(casing=Casing.SNAKE), stream=True)
|
|
73
73
|
if response.status_code != 200:
|
|
74
74
|
print(f"Failed to send inference request. Status code: {response.status_code}. Error: {response.text}")
|
|
75
75
|
return
|
|
@@ -37,7 +37,7 @@ class MaitaiClient:
|
|
|
37
37
|
threading.Thread(target=run).start()
|
|
38
38
|
|
|
39
39
|
@classmethod
|
|
40
|
-
def create_inference_request(cls, application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params: ChatCompletionParams):
|
|
40
|
+
def create_inference_request(cls, application_ref_name, session_id, reference_id, action_type, apply_corrections, evaluation_enabled, completion_params: ChatCompletionParams, callback):
|
|
41
41
|
infer_request: ChatCompletionRequest = ChatCompletionRequest()
|
|
42
42
|
infer_request.application_ref_name = application_ref_name
|
|
43
43
|
infer_request.reference_id = reference_id
|
|
@@ -47,4 +47,5 @@ class MaitaiClient:
|
|
|
47
47
|
infer_request.params = completion_params
|
|
48
48
|
infer_request.evaluation_enabled = evaluation_enabled
|
|
49
49
|
infer_request.auth_info = config.auth_info
|
|
50
|
+
infer_request.return_evaluation = True if callback else False
|
|
50
51
|
return infer_request
|
|
@@ -26,6 +26,8 @@ class MaitaiOpenAIClient:
|
|
|
26
26
|
*,
|
|
27
27
|
maitai_api_key: Optional[str] = None,
|
|
28
28
|
api_key: Optional[str] = None,
|
|
29
|
+
openai_api_key: Optional[str] = None,
|
|
30
|
+
groq_api_key: Optional[str] = None,
|
|
29
31
|
organization: Optional[str] = None,
|
|
30
32
|
project: Optional[str] = None,
|
|
31
33
|
base_url: Union[str, httpx.URL, None] = None,
|
|
@@ -36,10 +38,14 @@ class MaitaiOpenAIClient:
|
|
|
36
38
|
http_client: Optional[httpx.Client] = None,
|
|
37
39
|
_strict_response_validation: bool = False,
|
|
38
40
|
):
|
|
41
|
+
if api_key:
|
|
42
|
+
raise ValueError("The api_key parameter is not supported by Maitai. Provide openai_api_key or groq_api_key instead")
|
|
39
43
|
if maitai_api_key:
|
|
40
44
|
config.initialize(maitai_api_key)
|
|
41
|
-
if
|
|
42
|
-
config.auth_info.
|
|
45
|
+
if openai_api_key:
|
|
46
|
+
config.auth_info.openai_api_key = openai_api_key
|
|
47
|
+
if groq_api_key:
|
|
48
|
+
config.auth_info.groq_api_key = groq_api_key
|
|
43
49
|
self.client = openai.OpenAI(
|
|
44
50
|
api_key=api_key,
|
|
45
51
|
organization=organization,
|
|
@@ -135,6 +141,10 @@ class Completions:
|
|
|
135
141
|
max_tokens = maitai_config.max_tokens
|
|
136
142
|
if n == openai.NOT_GIVEN:
|
|
137
143
|
n = maitai_config.n
|
|
144
|
+
if frequency_penalty == openai.NOT_GIVEN:
|
|
145
|
+
frequency_penalty = maitai_config.frequency_penalty
|
|
146
|
+
if presence_penalty == openai.NOT_GIVEN:
|
|
147
|
+
presence_penalty = maitai_config.presence_penalty
|
|
138
148
|
completion_params = get_chat_completion_params(
|
|
139
149
|
messages=messages,
|
|
140
150
|
model=model,
|
|
@@ -26,6 +26,8 @@ class MaitaiAsyncOpenAIClient:
|
|
|
26
26
|
*,
|
|
27
27
|
maitai_api_key: Optional[str] = None,
|
|
28
28
|
api_key: Optional[str] = None,
|
|
29
|
+
openai_api_key: Optional[str] = None,
|
|
30
|
+
groq_api_key: Optional[str] = None,
|
|
29
31
|
organization: Optional[str] = None,
|
|
30
32
|
project: Optional[str] = None,
|
|
31
33
|
base_url: Union[str, httpx.URL, None] = None,
|
|
@@ -37,10 +39,14 @@ class MaitaiAsyncOpenAIClient:
|
|
|
37
39
|
_strict_response_validation: bool = False,
|
|
38
40
|
|
|
39
41
|
):
|
|
42
|
+
if api_key:
|
|
43
|
+
raise ValueError("The api_key parameter is not supported by Maitai. Provide openai_api_key or groq_api_key instead")
|
|
40
44
|
if maitai_api_key:
|
|
41
45
|
config.initialize(maitai_api_key)
|
|
42
|
-
if
|
|
43
|
-
config.auth_info.
|
|
46
|
+
if openai_api_key:
|
|
47
|
+
config.auth_info.openai_api_key = openai_api_key
|
|
48
|
+
if groq_api_key:
|
|
49
|
+
config.auth_info.groq_api_key = groq_api_key
|
|
44
50
|
self.client = openai.AsyncClient(
|
|
45
51
|
api_key=api_key,
|
|
46
52
|
organization=organization,
|
|
@@ -140,6 +146,10 @@ class AsyncCompletions:
|
|
|
140
146
|
max_tokens = maitai_config.max_tokens
|
|
141
147
|
if n == openai.NOT_GIVEN:
|
|
142
148
|
n = maitai_config.n
|
|
149
|
+
if frequency_penalty == openai.NOT_GIVEN:
|
|
150
|
+
frequency_penalty = maitai_config.frequency_penalty
|
|
151
|
+
if presence_penalty == openai.NOT_GIVEN:
|
|
152
|
+
presence_penalty = maitai_config.presence_penalty
|
|
143
153
|
|
|
144
154
|
completion_params = get_chat_completion_params(
|
|
145
155
|
messages=messages,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from maitai_back.utils import misc_utils
|
|
2
|
+
from maitai_gen.config import Config, InferenceLocations, ModelConfig
|
|
2
3
|
|
|
3
4
|
# TODO consider finding a source of truth where we don't need to deploy everytime a new model comes out
|
|
4
5
|
SERVER_PROVIDERS = ["groq", "openai"]
|
|
@@ -30,6 +31,9 @@ MODELS = {
|
|
|
30
31
|
"gpt-3.5-turbo-16k-0613": "openai",
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
DEFAULT_CLIENT_MODEL = "gpt-4o"
|
|
35
|
+
DEFAULT_SERVER_MODEL = "llama3-70b-8192"
|
|
36
|
+
|
|
33
37
|
|
|
34
38
|
def get_default_config() -> Config:
|
|
35
39
|
return Config(
|
|
@@ -37,16 +41,26 @@ def get_default_config() -> Config:
|
|
|
37
41
|
evaluation_enabled=True,
|
|
38
42
|
apply_corrections=True,
|
|
39
43
|
model='gpt-4o',
|
|
40
|
-
temperature=
|
|
44
|
+
temperature=1,
|
|
41
45
|
streaming=False,
|
|
42
46
|
response_format="text",
|
|
43
47
|
stop=None,
|
|
44
48
|
logprobs=False,
|
|
45
49
|
max_tokens=None,
|
|
46
50
|
n=1,
|
|
51
|
+
frequency_penalty=0,
|
|
52
|
+
presence_penalty=0,
|
|
47
53
|
)
|
|
48
54
|
|
|
49
55
|
|
|
56
|
+
def reconcile_config_with_default(config_dict: dict) -> Config:
|
|
57
|
+
default_config_json = misc_utils.to_dict(get_default_config())
|
|
58
|
+
for key, value in default_config_json.items():
|
|
59
|
+
if key not in config_dict:
|
|
60
|
+
config_dict[key] = value
|
|
61
|
+
return Config().from_pydict(config_dict)
|
|
62
|
+
|
|
63
|
+
|
|
50
64
|
def get_model_provider(model_name: str):
|
|
51
65
|
return MODELS[model_name]
|
|
52
66
|
|
|
@@ -60,4 +74,11 @@ def get_models(providers):
|
|
|
60
74
|
|
|
61
75
|
|
|
62
76
|
def get_available_models():
|
|
63
|
-
|
|
77
|
+
model_config = ModelConfig(
|
|
78
|
+
all_models=list(MODELS.keys()),
|
|
79
|
+
client_models=get_models(CLIENT_PROVIDERS),
|
|
80
|
+
server_models=get_models(SERVER_PROVIDERS),
|
|
81
|
+
default_client_model=DEFAULT_CLIENT_MODEL,
|
|
82
|
+
default_server_model=DEFAULT_SERVER_MODEL,
|
|
83
|
+
)
|
|
84
|
+
return misc_utils.to_dict(model_config)
|
|
@@ -44,6 +44,8 @@ class Application(betterproto.Message):
|
|
|
44
44
|
meta: "_config__.Config" = betterproto.message_field(8)
|
|
45
45
|
action_types: List["ApplicationAction"] = betterproto.message_field(9)
|
|
46
46
|
last_activity: int = betterproto.int64_field(10)
|
|
47
|
+
fault_notifications: bool = betterproto.bool_field(11)
|
|
48
|
+
session_summaries: bool = betterproto.bool_field(12)
|
|
47
49
|
|
|
48
50
|
|
|
49
51
|
@dataclass(eq=False, repr=False)
|
|
@@ -54,3 +56,4 @@ class ApplicationAction(betterproto.Message):
|
|
|
54
56
|
application_id: int = betterproto.int64_field(4)
|
|
55
57
|
meta: "_config__.Config" = betterproto.message_field(5)
|
|
56
58
|
last_activity: int = betterproto.int64_field(6)
|
|
59
|
+
notifications_enabled: bool = betterproto.bool_field(7)
|
|
@@ -13,6 +13,7 @@ from typing import (
|
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
import betterproto
|
|
16
|
+
import betterproto.lib.google.protobuf as betterproto_lib_google_protobuf
|
|
16
17
|
import grpclib
|
|
17
18
|
from betterproto.grpc.grpclib_server import ServiceBase
|
|
18
19
|
|
|
@@ -25,6 +26,11 @@ if TYPE_CHECKING:
|
|
|
25
26
|
from grpclib.metadata import Deadline
|
|
26
27
|
|
|
27
28
|
|
|
29
|
+
class EvaluationProvider(betterproto.Enum):
|
|
30
|
+
GROQ = 0
|
|
31
|
+
OPENAI = 1
|
|
32
|
+
|
|
33
|
+
|
|
28
34
|
class EvaluationContentType(betterproto.Enum):
|
|
29
35
|
MESSAGE = 0
|
|
30
36
|
TEXT = 1
|
|
@@ -45,6 +51,7 @@ class ChatCompletionRequest(betterproto.Message):
|
|
|
45
51
|
request_id: str = betterproto.string_field(10)
|
|
46
52
|
evaluation_enabled: bool = betterproto.bool_field(11)
|
|
47
53
|
auth_info: "ChatCompletionAuth" = betterproto.message_field(12)
|
|
54
|
+
return_evaluation: bool = betterproto.bool_field(13)
|
|
48
55
|
|
|
49
56
|
|
|
50
57
|
@dataclass(eq=False, repr=False)
|
|
@@ -279,7 +286,7 @@ class EvaluationServiceStub(betterproto.ServiceStub):
|
|
|
279
286
|
metadata=metadata,
|
|
280
287
|
)
|
|
281
288
|
|
|
282
|
-
async def
|
|
289
|
+
async def stream_correction(
|
|
283
290
|
self,
|
|
284
291
|
evaluate_request: "EvaluateRequest",
|
|
285
292
|
*,
|
|
@@ -288,7 +295,7 @@ class EvaluationServiceStub(betterproto.ServiceStub):
|
|
|
288
295
|
metadata: Optional["MetadataLike"] = None
|
|
289
296
|
) -> AsyncIterator["ChatCompletionChunk"]:
|
|
290
297
|
async for response in self._unary_stream(
|
|
291
|
-
"/chat.EvaluationService/
|
|
298
|
+
"/chat.EvaluationService/StreamCorrection",
|
|
292
299
|
evaluate_request,
|
|
293
300
|
ChatCompletionChunk,
|
|
294
301
|
timeout=timeout,
|
|
@@ -297,18 +304,40 @@ class EvaluationServiceStub(betterproto.ServiceStub):
|
|
|
297
304
|
):
|
|
298
305
|
yield response
|
|
299
306
|
|
|
307
|
+
async def evaluate_async(
|
|
308
|
+
self,
|
|
309
|
+
evaluate_request: "EvaluateRequest",
|
|
310
|
+
*,
|
|
311
|
+
timeout: Optional[float] = None,
|
|
312
|
+
deadline: Optional["Deadline"] = None,
|
|
313
|
+
metadata: Optional["MetadataLike"] = None
|
|
314
|
+
) -> "betterproto_lib_google_protobuf.Empty":
|
|
315
|
+
return await self._unary_unary(
|
|
316
|
+
"/chat.EvaluationService/EvaluateAsync",
|
|
317
|
+
evaluate_request,
|
|
318
|
+
betterproto_lib_google_protobuf.Empty,
|
|
319
|
+
timeout=timeout,
|
|
320
|
+
deadline=deadline,
|
|
321
|
+
metadata=metadata,
|
|
322
|
+
)
|
|
323
|
+
|
|
300
324
|
|
|
301
325
|
class EvaluationServiceBase(ServiceBase):
|
|
302
326
|
|
|
303
327
|
async def evaluate(self, evaluate_request: "EvaluateRequest") -> "EvaluateResponse":
|
|
304
328
|
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
305
329
|
|
|
306
|
-
async def
|
|
330
|
+
async def stream_correction(
|
|
307
331
|
self, evaluate_request: "EvaluateRequest"
|
|
308
332
|
) -> AsyncIterator["ChatCompletionChunk"]:
|
|
309
333
|
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
310
334
|
yield ChatCompletionChunk()
|
|
311
335
|
|
|
336
|
+
async def evaluate_async(
|
|
337
|
+
self, evaluate_request: "EvaluateRequest"
|
|
338
|
+
) -> "betterproto_lib_google_protobuf.Empty":
|
|
339
|
+
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
340
|
+
|
|
312
341
|
async def __rpc_evaluate(
|
|
313
342
|
self, stream: "grpclib.server.Stream[EvaluateRequest, EvaluateResponse]"
|
|
314
343
|
) -> None:
|
|
@@ -316,16 +345,24 @@ class EvaluationServiceBase(ServiceBase):
|
|
|
316
345
|
response = await self.evaluate(request)
|
|
317
346
|
await stream.send_message(response)
|
|
318
347
|
|
|
319
|
-
async def
|
|
348
|
+
async def __rpc_stream_correction(
|
|
320
349
|
self, stream: "grpclib.server.Stream[EvaluateRequest, ChatCompletionChunk]"
|
|
321
350
|
) -> None:
|
|
322
351
|
request = await stream.recv_message()
|
|
323
352
|
await self._call_rpc_handler_server_stream(
|
|
324
|
-
self.
|
|
353
|
+
self.stream_correction,
|
|
325
354
|
stream,
|
|
326
355
|
request,
|
|
327
356
|
)
|
|
328
357
|
|
|
358
|
+
async def __rpc_evaluate_async(
|
|
359
|
+
self,
|
|
360
|
+
stream: "grpclib.server.Stream[EvaluateRequest, betterproto_lib_google_protobuf.Empty]",
|
|
361
|
+
) -> None:
|
|
362
|
+
request = await stream.recv_message()
|
|
363
|
+
response = await self.evaluate_async(request)
|
|
364
|
+
await stream.send_message(response)
|
|
365
|
+
|
|
329
366
|
def __mapping__(self) -> Dict[str, grpclib.const.Handler]:
|
|
330
367
|
return {
|
|
331
368
|
"/chat.EvaluationService/Evaluate": grpclib.const.Handler(
|
|
@@ -334,10 +371,16 @@ class EvaluationServiceBase(ServiceBase):
|
|
|
334
371
|
EvaluateRequest,
|
|
335
372
|
EvaluateResponse,
|
|
336
373
|
),
|
|
337
|
-
"/chat.EvaluationService/
|
|
338
|
-
self.
|
|
374
|
+
"/chat.EvaluationService/StreamCorrection": grpclib.const.Handler(
|
|
375
|
+
self.__rpc_stream_correction,
|
|
339
376
|
grpclib.const.Cardinality.UNARY_STREAM,
|
|
340
377
|
EvaluateRequest,
|
|
341
378
|
ChatCompletionChunk,
|
|
342
379
|
),
|
|
380
|
+
"/chat.EvaluationService/EvaluateAsync": grpclib.const.Handler(
|
|
381
|
+
self.__rpc_evaluate_async,
|
|
382
|
+
grpclib.const.Cardinality.UNARY_UNARY,
|
|
383
|
+
EvaluateRequest,
|
|
384
|
+
betterproto_lib_google_protobuf.Empty,
|
|
385
|
+
),
|
|
343
386
|
}
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
# This file has been @generated
|
|
5
5
|
|
|
6
6
|
from dataclasses import dataclass
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import (
|
|
8
|
+
List,
|
|
9
|
+
Optional,
|
|
10
|
+
)
|
|
8
11
|
|
|
9
12
|
import betterproto
|
|
10
13
|
|
|
@@ -29,3 +32,14 @@ class Config(betterproto.Message):
|
|
|
29
32
|
10, optional=True, group="_max_tokens"
|
|
30
33
|
)
|
|
31
34
|
n: int = betterproto.int64_field(11)
|
|
35
|
+
presence_penalty: float = betterproto.double_field(15)
|
|
36
|
+
frequency_penalty: float = betterproto.double_field(16)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass(eq=False, repr=False)
|
|
40
|
+
class ModelConfig(betterproto.Message):
|
|
41
|
+
all_models: List[str] = betterproto.string_field(1)
|
|
42
|
+
client_models: List[str] = betterproto.string_field(2)
|
|
43
|
+
server_models: List[str] = betterproto.string_field(3)
|
|
44
|
+
default_client_model: str = betterproto.string_field(4)
|
|
45
|
+
default_server_model: str = betterproto.string_field(5)
|
|
@@ -36,6 +36,11 @@ class Session(betterproto.Message):
|
|
|
36
36
|
reviewer: Dict[str, str] = betterproto.map_field(
|
|
37
37
|
9, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
|
38
38
|
)
|
|
39
|
+
date_ended: int = betterproto.int64_field(10)
|
|
40
|
+
company_id: int = betterproto.int64_field(11)
|
|
41
|
+
meta: Dict[str, str] = betterproto.map_field(
|
|
42
|
+
12, betterproto.TYPE_STRING, betterproto.TYPE_STRING
|
|
43
|
+
)
|
|
39
44
|
|
|
40
45
|
|
|
41
46
|
@dataclass(eq=False, repr=False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{maitai_python-1.0.19 → maitai_python-1.0.21}/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
|