mito-ai 0.1.58__py3-none-any.whl → 0.1.60__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.
- mito_ai/__init__.py +5 -2
- mito_ai/_version.py +1 -1
- mito_ai/completions/prompt_builders/agent_system_message.py +7 -1
- mito_ai/completions/prompt_builders/chat_system_message.py +4 -0
- mito_ai/completions/prompt_builders/prompt_constants.py +17 -0
- mito_ai/constants.py +25 -3
- mito_ai/enterprise/litellm_client.py +12 -5
- mito_ai/enterprise/utils.py +16 -2
- mito_ai/openai_client.py +26 -6
- mito_ai/provider_manager.py +34 -2
- mito_ai/rules/handlers.py +46 -12
- mito_ai/rules/utils.py +170 -6
- mito_ai/tests/message_history/test_generate_short_chat_name.py +35 -4
- mito_ai/tests/open_ai_utils_test.py +34 -36
- mito_ai/tests/providers/test_azure.py +2 -2
- mito_ai/tests/providers/test_providers.py +5 -5
- mito_ai/tests/rules/rules_test.py +100 -4
- mito_ai/tests/test_constants.py +90 -0
- mito_ai/tests/test_enterprise_mode.py +55 -0
- mito_ai/tests/test_model_utils.py +116 -25
- mito_ai/utils/anthropic_utils.py +1 -2
- mito_ai/utils/model_utils.py +130 -53
- mito_ai/utils/open_ai_utils.py +29 -33
- mito_ai/utils/provider_utils.py +13 -7
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/build_log.json +1 -1
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/package.json +2 -2
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/schemas/mito_ai/package.json.orig +1 -1
- mito_ai-0.1.58.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.03302cc521d72eb56b00.js → mito_ai-0.1.60.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.dccfa541c464ee0e5cd4.js +1064 -175
- mito_ai-0.1.60.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.dccfa541c464ee0e5cd4.js.map +1 -0
- mito_ai-0.1.58.data/data/share/jupyter/labextensions/mito_ai/static/style_index_js.f5d476ac514294615881.js → mito_ai-0.1.60.data/data/share/jupyter/labextensions/mito_ai/static/node_modules_css-loader_dist_cjs_js_style_base_css.3594c54c9d209e1ed56e.js +2 -460
- mito_ai-0.1.60.data/data/share/jupyter/labextensions/mito_ai/static/node_modules_css-loader_dist_cjs_js_style_base_css.3594c54c9d209e1ed56e.js.map +1 -0
- mito_ai-0.1.60.data/data/share/jupyter/labextensions/mito_ai/static/node_modules_css-loader_dist_runtime_api_js-node_modules_css-loader_dist_runtime_sourceMaps_j-49e54d.3972dd8e7542bba478ad.js +463 -0
- mito_ai-0.1.60.data/data/share/jupyter/labextensions/mito_ai/static/node_modules_css-loader_dist_runtime_api_js-node_modules_css-loader_dist_runtime_sourceMaps_j-49e54d.3972dd8e7542bba478ad.js.map +1 -0
- mito_ai-0.1.58.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.570df809a692f53a7ab7.js → mito_ai-0.1.60.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.9735d9bfc8891147fee0.js +6 -6
- mito_ai-0.1.60.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.9735d9bfc8891147fee0.js.map +1 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/themes/mito_ai/index.css +78 -78
- {mito_ai-0.1.58.dist-info → mito_ai-0.1.60.dist-info}/METADATA +1 -1
- {mito_ai-0.1.58.dist-info → mito_ai-0.1.60.dist-info}/RECORD +61 -59
- mito_ai-0.1.58.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.03302cc521d72eb56b00.js.map +0 -1
- mito_ai-0.1.58.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.570df809a692f53a7ab7.js.map +0 -1
- mito_ai-0.1.58.data/data/share/jupyter/labextensions/mito_ai/static/style_index_js.f5d476ac514294615881.js.map +0 -1
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/etc/jupyter/jupyter_server_config.d/mito_ai.json +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/schemas/mito_ai/toolbar-buttons.json +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/node_modules_process_browser_js.4b128e94d31a81ebd209.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/node_modules_process_browser_js.4b128e94d31a81ebd209.js.map +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/style.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_auth_dist_esm_providers_cognito_apis_signOut_mjs-node_module-75790d.688c25857e7b81b1740f.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_auth_dist_esm_providers_cognito_apis_signOut_mjs-node_module-75790d.688c25857e7b81b1740f.js.map +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_auth_dist_esm_providers_cognito_tokenProvider_tokenProvider_-72f1c8.a917210f057fcfe224ad.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_auth_dist_esm_providers_cognito_tokenProvider_tokenProvider_-72f1c8.a917210f057fcfe224ad.js.map +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_dist_esm_index_mjs.6bac1a8c4cc93f15f6b7.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_dist_esm_index_mjs.6bac1a8c4cc93f15f6b7.js.map +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_ui-react_dist_esm_index_mjs.4fcecd65bef9e9847609.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_ui-react_dist_esm_index_mjs.4fcecd65bef9e9847609.js.map +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_react-dom_client_js-node_modules_aws-amplify_ui-react_dist_styles_css.b43d4249e4d3dac9ad7b.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_react-dom_client_js-node_modules_aws-amplify_ui-react_dist_styles_css.b43d4249e4d3dac9ad7b.js.map +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_semver_index_js.3f6754ac5116d47de76b.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_semver_index_js.3f6754ac5116d47de76b.js.map +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_vscode-diff_dist_index_js.ea55f1f9346638aafbcf.js +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_vscode-diff_dist_index_js.ea55f1f9346638aafbcf.js.map +0 -0
- {mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/themes/mito_ai/index.js +0 -0
- {mito_ai-0.1.58.dist-info → mito_ai-0.1.60.dist-info}/WHEEL +0 -0
- {mito_ai-0.1.58.dist-info → mito_ai-0.1.60.dist-info}/entry_points.txt +0 -0
- {mito_ai-0.1.58.dist-info → mito_ai-0.1.60.dist-info}/licenses/LICENSE +0 -0
mito_ai/utils/open_ai_utils.py
CHANGED
|
@@ -6,30 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
# Copyright (c) Saga Inc.
|
|
8
8
|
|
|
9
|
-
import
|
|
10
|
-
import json
|
|
11
|
-
import time
|
|
12
|
-
from typing import Any, Dict, List, Optional, Final, Union, AsyncGenerator, Tuple, Callable
|
|
9
|
+
from typing import Any, Dict, List, Optional, Union, AsyncGenerator, Tuple, Callable
|
|
13
10
|
from mito_ai.utils.mito_server_utils import get_response_from_mito_server, stream_response_from_mito_server
|
|
14
|
-
from tornado.httpclient import AsyncHTTPClient
|
|
15
11
|
from openai.types.chat import ChatCompletionMessageParam
|
|
16
|
-
|
|
17
|
-
from mito_ai.utils.utils import is_running_test
|
|
18
|
-
from mito_ai.completions.models import MessageType, ResponseFormatInfo, CompletionReply, CompletionStreamChunk, CompletionItem
|
|
12
|
+
from mito_ai.completions.models import MessageType, ResponseFormatInfo, CompletionReply, CompletionStreamChunk
|
|
19
13
|
from mito_ai.utils.schema import UJ_STATIC_USER_ID, UJ_USER_EMAIL
|
|
20
14
|
from mito_ai.utils.db import get_user_field
|
|
21
|
-
from mito_ai.utils
|
|
22
|
-
from mito_ai.utils.server_limits import check_mito_server_quota
|
|
23
|
-
from mito_ai.utils.telemetry_utils import log_ai_completion_success
|
|
24
|
-
from .utils import _create_http_client
|
|
15
|
+
from mito_ai.enterprise.utils import is_abacus_configured
|
|
25
16
|
from mito_ai.constants import MITO_OPENAI_URL
|
|
26
17
|
|
|
27
|
-
|
|
28
18
|
__user_email: Optional[str] = None
|
|
29
19
|
__user_id: Optional[str] = None
|
|
30
20
|
|
|
31
|
-
FAST_OPENAI_MODEL = "gpt-4.1-nano"
|
|
32
|
-
|
|
33
21
|
def _prepare_request_data_and_headers(
|
|
34
22
|
last_message_content: Union[str, None],
|
|
35
23
|
ai_completion_data: Dict[str, Any],
|
|
@@ -171,25 +159,33 @@ def get_open_ai_completion_function_params(
|
|
|
171
159
|
# Pydantic models are supported by the OpenAI API, however, we need to be able to
|
|
172
160
|
# serialize it for requests that are going to be sent to the mito server.
|
|
173
161
|
# OpenAI expects a very specific schema as seen below.
|
|
162
|
+
# Note: Abacus only supports {"type": "json"} format, not the full JSON schema format.
|
|
174
163
|
if response_format_info:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
"json_schema
|
|
189
|
-
"
|
|
190
|
-
|
|
191
|
-
|
|
164
|
+
# Check if we're using Abacus - it only supports simple {"type": "json"} format
|
|
165
|
+
if is_abacus_configured() or model.lower().startswith('abacus/'):
|
|
166
|
+
completion_function_params["response_format"] = {
|
|
167
|
+
"type": "json"
|
|
168
|
+
}
|
|
169
|
+
else:
|
|
170
|
+
# For OpenAI and other providers, use the full JSON schema format
|
|
171
|
+
json_schema = response_format_info.format.schema()
|
|
172
|
+
|
|
173
|
+
# Add additionalProperties: False to the top-level schema
|
|
174
|
+
json_schema["additionalProperties"] = False
|
|
175
|
+
|
|
176
|
+
# Nested object definitions in $defs need to have additionalProperties set to False also
|
|
177
|
+
if "$defs" in json_schema:
|
|
178
|
+
for def_name, def_schema in json_schema["$defs"].items():
|
|
179
|
+
if def_schema.get("type") == "object":
|
|
180
|
+
def_schema["additionalProperties"] = False
|
|
181
|
+
|
|
182
|
+
completion_function_params["response_format"] = {
|
|
183
|
+
"type": "json_schema",
|
|
184
|
+
"json_schema": {
|
|
185
|
+
"name": f"{response_format_info.name}",
|
|
186
|
+
"schema": json_schema,
|
|
187
|
+
"strict": True
|
|
188
|
+
}
|
|
192
189
|
}
|
|
193
|
-
}
|
|
194
190
|
|
|
195
191
|
return completion_function_params
|
mito_ai/utils/provider_utils.py
CHANGED
|
@@ -8,19 +8,25 @@ from mito_ai.completions.models import MessageType
|
|
|
8
8
|
|
|
9
9
|
def get_model_provider(model: str) -> Union[str, None]:
|
|
10
10
|
"""
|
|
11
|
-
Determine the model type based on the model name prefix
|
|
11
|
+
Determine the model type based on the model name prefix.
|
|
12
|
+
|
|
13
|
+
Priority order:
|
|
14
|
+
1. Check for router prefixes (Abacus/, LiteLLM/)
|
|
15
|
+
2. Check for legacy LiteLLM format (provider/model)
|
|
16
|
+
3. Check for standard model name patterns
|
|
12
17
|
"""
|
|
13
18
|
if not model:
|
|
14
19
|
return None
|
|
15
20
|
|
|
16
|
-
# Check if model is a LiteLLM model (has provider prefix)
|
|
17
|
-
if "/" in model and any(
|
|
18
|
-
model.startswith(prefix) for prefix in ["openai/", "anthropic/", "google/", "ollama/"]
|
|
19
|
-
):
|
|
20
|
-
return 'litellm'
|
|
21
|
-
|
|
22
21
|
model_lower = model.lower()
|
|
23
22
|
|
|
23
|
+
# Check for router prefixes first (highest priority)
|
|
24
|
+
if model_lower.startswith('abacus/'):
|
|
25
|
+
return 'abacus'
|
|
26
|
+
elif model_lower.startswith('litellm/'):
|
|
27
|
+
return 'litellm'
|
|
28
|
+
|
|
29
|
+
# Check for standard model name patterns
|
|
24
30
|
if model_lower.startswith('claude'):
|
|
25
31
|
return 'claude'
|
|
26
32
|
elif model_lower.startswith('gemini'):
|
{mito_ai-0.1.58.data → mito_ai-0.1.60.data}/data/share/jupyter/labextensions/mito_ai/package.json
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mito_ai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.60",
|
|
4
4
|
"description": "AI chat for JupyterLab",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"schemaDir": "schema",
|
|
142
142
|
"themePath": "style/theme/theme.css",
|
|
143
143
|
"_build": {
|
|
144
|
-
"load": "static/remoteEntry.
|
|
144
|
+
"load": "static/remoteEntry.9735d9bfc8891147fee0.js",
|
|
145
145
|
"extension": "./extension",
|
|
146
146
|
"style": "./style"
|
|
147
147
|
}
|