mito-ai 0.1.46__py3-none-any.whl → 0.1.47__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.
Potentially problematic release.
This version of mito-ai might be problematic. Click here for more details.
- mito_ai/_version.py +1 -1
- mito_ai/app_deploy/handlers.py +97 -77
- mito_ai/app_deploy/models.py +16 -12
- mito_ai/completions/models.py +4 -1
- mito_ai/completions/prompt_builders/agent_execution_prompt.py +6 -1
- mito_ai/completions/prompt_builders/agent_system_message.py +63 -4
- mito_ai/completions/prompt_builders/chat_system_message.py +4 -0
- mito_ai/completions/prompt_builders/prompt_constants.py +1 -0
- mito_ai/completions/prompt_builders/utils.py +14 -0
- mito_ai/path_utils.py +56 -0
- mito_ai/streamlit_conversion/agent_utils.py +4 -201
- mito_ai/streamlit_conversion/prompts/prompt_constants.py +142 -152
- mito_ai/streamlit_conversion/prompts/streamlit_error_correction_prompt.py +3 -3
- mito_ai/streamlit_conversion/prompts/streamlit_finish_todo_prompt.py +2 -2
- mito_ai/streamlit_conversion/prompts/update_existing_app_prompt.py +2 -2
- mito_ai/streamlit_conversion/search_replace_utils.py +93 -0
- mito_ai/streamlit_conversion/streamlit_agent_handler.py +29 -39
- mito_ai/streamlit_conversion/streamlit_utils.py +11 -64
- mito_ai/streamlit_conversion/validate_streamlit_app.py +5 -18
- mito_ai/streamlit_preview/handlers.py +44 -84
- mito_ai/streamlit_preview/manager.py +6 -6
- mito_ai/streamlit_preview/utils.py +16 -19
- mito_ai/tests/streamlit_conversion/test_apply_search_replace.py +226 -0
- mito_ai/tests/streamlit_conversion/test_streamlit_agent_handler.py +29 -53
- mito_ai/tests/streamlit_conversion/test_streamlit_utils.py +26 -29
- mito_ai/tests/streamlit_conversion/test_validate_streamlit_app.py +6 -3
- mito_ai/tests/streamlit_preview/test_streamlit_preview_handler.py +12 -15
- mito_ai/tests/streamlit_preview/test_streamlit_preview_manager.py +22 -26
- mito_ai/user/handlers.py +15 -3
- mito_ai/utils/create.py +17 -1
- mito_ai/utils/error_classes.py +42 -0
- mito_ai/utils/message_history_utils.py +3 -1
- mito_ai/utils/telemetry_utils.py +75 -10
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/build_log.json +1 -1
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/package.json +2 -2
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/schemas/mito_ai/package.json.orig +1 -1
- mito_ai-0.1.46.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.20f12766ecd3d430568e.js → mito_ai-0.1.47.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.2db61d2b629817845901.js +1274 -293
- mito_ai-0.1.47.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.2db61d2b629817845901.js.map +1 -0
- mito_ai-0.1.46.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.54126ab6511271265443.js → mito_ai-0.1.47.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.e22c6cd4e56c32116daa.js +7 -7
- mito_ai-0.1.46.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.54126ab6511271265443.js.map → mito_ai-0.1.47.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.e22c6cd4e56c32116daa.js.map +1 -1
- {mito_ai-0.1.46.dist-info → mito_ai-0.1.47.dist-info}/METADATA +1 -1
- {mito_ai-0.1.46.dist-info → mito_ai-0.1.47.dist-info}/RECORD +67 -65
- mito_ai/tests/streamlit_conversion/test_apply_patch_to_text.py +0 -368
- mito_ai/tests/streamlit_conversion/test_fix_diff_headers.py +0 -533
- mito_ai-0.1.46.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.20f12766ecd3d430568e.js.map +0 -1
- /mito_ai/streamlit_conversion/{streamlit_system_prompt.py → prompts/streamlit_system_prompt.py} +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/etc/jupyter/jupyter_server_config.d/mito_ai.json +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/schemas/mito_ai/toolbar-buttons.json +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/static/node_modules_process_browser_js.4b128e94d31a81ebd209.js +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/static/node_modules_process_browser_js.4b128e94d31a81ebd209.js.map +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/static/style.js +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/static/style_index_js.5876024bb17dbd6a3ee6.js +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/static/style_index_js.5876024bb17dbd6a3ee6.js.map +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.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.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_semver_index_js.3f6754ac5116d47de76b.js +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_semver_index_js.3f6754ac5116d47de76b.js.map +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_vscode-diff_dist_index_js.ea55f1f9346638aafbcf.js +0 -0
- {mito_ai-0.1.46.data → mito_ai-0.1.47.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.46.dist-info → mito_ai-0.1.47.dist-info}/WHEEL +0 -0
- {mito_ai-0.1.46.dist-info → mito_ai-0.1.47.dist-info}/entry_points.txt +0 -0
- {mito_ai-0.1.46.dist-info → mito_ai-0.1.47.dist-info}/licenses/LICENSE +0 -0
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import pytest
|
|
5
5
|
import os
|
|
6
6
|
import tempfile
|
|
7
|
-
from unittest.mock import patch
|
|
7
|
+
from unittest.mock import patch
|
|
8
8
|
from mito_ai.streamlit_preview.utils import ensure_app_exists
|
|
9
|
+
from mito_ai.path_utils import AbsoluteNotebookPath, get_absolute_notebook_path
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class TestEnsureAppExists:
|
|
@@ -13,14 +14,12 @@ class TestEnsureAppExists:
|
|
|
13
14
|
|
|
14
15
|
@pytest.mark.asyncio
|
|
15
16
|
@pytest.mark.parametrize(
|
|
16
|
-
"app_exists,streamlit_handler_success,
|
|
17
|
+
"app_exists,streamlit_handler_success,streamlit_handler_called,streamlit_handler_return",
|
|
17
18
|
[
|
|
18
19
|
# Test case 1: App exists, should use existing file
|
|
19
20
|
(
|
|
20
21
|
True, # app_exists
|
|
21
22
|
True, # streamlit_handler_success (not relevant)
|
|
22
|
-
True, # expected_success
|
|
23
|
-
"", # expected_error
|
|
24
23
|
False, # streamlit_handler_called
|
|
25
24
|
None, # streamlit_handler_return (not used)
|
|
26
25
|
),
|
|
@@ -28,10 +27,8 @@ class TestEnsureAppExists:
|
|
|
28
27
|
(
|
|
29
28
|
False, # app_exists
|
|
30
29
|
True, # streamlit_handler_success
|
|
31
|
-
True, # expected_success
|
|
32
|
-
"", # expected_error
|
|
33
30
|
True, # streamlit_handler_called
|
|
34
|
-
|
|
31
|
+
"/path/to/app.py", # streamlit_handler_return
|
|
35
32
|
)
|
|
36
33
|
],
|
|
37
34
|
ids=[
|
|
@@ -43,8 +40,6 @@ class TestEnsureAppExists:
|
|
|
43
40
|
self,
|
|
44
41
|
app_exists,
|
|
45
42
|
streamlit_handler_success,
|
|
46
|
-
expected_success,
|
|
47
|
-
expected_error,
|
|
48
43
|
streamlit_handler_called,
|
|
49
44
|
streamlit_handler_return,
|
|
50
45
|
):
|
|
@@ -62,19 +57,21 @@ class TestEnsureAppExists:
|
|
|
62
57
|
f.write("import streamlit as st\nst.write('Hello World')")
|
|
63
58
|
|
|
64
59
|
# Mock get_app_path to return the appropriate value
|
|
65
|
-
with patch('mito_ai.streamlit_preview.utils.
|
|
60
|
+
with patch('mito_ai.streamlit_preview.utils.get_absolute_notebook_dir_path') as mock_get_dir_path, \
|
|
61
|
+
patch('mito_ai.streamlit_preview.utils.get_absolute_app_path') as mock_get_app_path, \
|
|
62
|
+
patch('mito_ai.streamlit_preview.utils.does_app_path_exists') as mock_app_exists:
|
|
63
|
+
|
|
64
|
+
# Set up mocks
|
|
65
|
+
mock_get_dir_path.return_value = temp_dir
|
|
66
66
|
mock_get_app_path.return_value = app_path
|
|
67
|
+
mock_app_exists.return_value = app_exists
|
|
67
68
|
|
|
68
69
|
# Mock streamlit_handler
|
|
69
70
|
with patch('mito_ai.streamlit_preview.utils.streamlit_handler') as mock_streamlit_handler:
|
|
70
71
|
if streamlit_handler_return is not None:
|
|
71
72
|
mock_streamlit_handler.return_value = streamlit_handler_return
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
# Assertions
|
|
76
|
-
assert success == expected_success
|
|
77
|
-
assert error_msg == expected_error
|
|
74
|
+
await ensure_app_exists(AbsoluteNotebookPath(notebook_path), False, "")
|
|
78
75
|
|
|
79
76
|
# Verify get_app_path was called with the correct directory
|
|
80
77
|
mock_get_app_path.assert_called_once_with(temp_dir)
|
|
@@ -18,8 +18,6 @@ from mito_ai.streamlit_preview.manager import (
|
|
|
18
18
|
PreviewProcess,
|
|
19
19
|
get_preview_manager
|
|
20
20
|
)
|
|
21
|
-
from mito_ai.streamlit_preview.handlers import StreamlitPreviewHandler
|
|
22
|
-
from mito_ai.streamlit_conversion.streamlit_utils import get_app_path
|
|
23
21
|
|
|
24
22
|
|
|
25
23
|
class TestStreamlitPreviewManager:
|
|
@@ -81,25 +79,22 @@ st.write("Hello, World!")
|
|
|
81
79
|
mock_requests_get.return_value = mock_response
|
|
82
80
|
|
|
83
81
|
# Test
|
|
84
|
-
|
|
82
|
+
port = manager.start_streamlit_preview(app_directory, preview_id)
|
|
85
83
|
|
|
86
84
|
# Assertions
|
|
87
|
-
assert
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
# Cleanup
|
|
102
|
-
manager.stop_preview(preview_id)
|
|
85
|
+
assert isinstance(port, int)
|
|
86
|
+
assert port > 0
|
|
87
|
+
|
|
88
|
+
# Verify subprocess was called correctly
|
|
89
|
+
mock_popen.assert_called_once()
|
|
90
|
+
call_args = mock_popen.call_args
|
|
91
|
+
assert "streamlit" in call_args[0][0]
|
|
92
|
+
assert "run" in call_args[0][0]
|
|
93
|
+
assert "--server.headless" in call_args[0][0]
|
|
94
|
+
assert "--server.address" in call_args[0][0]
|
|
95
|
+
|
|
96
|
+
# Cleanup
|
|
97
|
+
manager.stop_preview(preview_id)
|
|
103
98
|
|
|
104
99
|
@pytest.mark.parametrize("exception_type,expected_message", [
|
|
105
100
|
(Exception("Temp dir creation failed"), "failed to start preview"),
|
|
@@ -108,13 +103,15 @@ st.write("Hello, World!")
|
|
|
108
103
|
])
|
|
109
104
|
def test_start_streamlit_preview_exceptions(self, manager, sample_app_code, exception_type, expected_message):
|
|
110
105
|
"""Test streamlit preview start with different exceptions."""
|
|
111
|
-
|
|
106
|
+
from mito_ai.utils.error_classes import StreamlitPreviewError
|
|
107
|
+
|
|
108
|
+
with patch('subprocess.Popen', side_effect=exception_type):
|
|
112
109
|
app_directory = "/tmp/test_dir"
|
|
113
|
-
success, message, port = manager.start_streamlit_preview(app_directory, "test_preview")
|
|
114
110
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
with pytest.raises(StreamlitPreviewError) as exc_info:
|
|
112
|
+
manager.start_streamlit_preview(app_directory, "test_preview")
|
|
113
|
+
|
|
114
|
+
assert expected_message in str(exc_info.value).lower()
|
|
118
115
|
|
|
119
116
|
@pytest.mark.parametrize("preview_id,expected_result", [
|
|
120
117
|
("existing_preview", True),
|
|
@@ -284,8 +281,7 @@ st.write("Hello, World!")
|
|
|
284
281
|
|
|
285
282
|
# Start multiple previews
|
|
286
283
|
for preview_id in preview_ids:
|
|
287
|
-
|
|
288
|
-
assert success is True
|
|
284
|
+
port = manager.start_streamlit_preview("/tmp/test_dir", preview_id)
|
|
289
285
|
ports.append(port)
|
|
290
286
|
|
|
291
287
|
# Assertions
|
mito_ai/user/handlers.py
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
5
|
import tornado
|
|
6
|
+
from typing import Any, Optional
|
|
6
7
|
from jupyter_server.base.handlers import APIHandler
|
|
7
8
|
from mito_ai.utils.db import get_user_field, set_user_field
|
|
8
9
|
from mito_ai.utils.telemetry_utils import identify
|
|
10
|
+
from mito_ai.utils.version_utils import is_pro
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class UserHandler(APIHandler):
|
|
@@ -13,7 +15,15 @@ class UserHandler(APIHandler):
|
|
|
13
15
|
|
|
14
16
|
@tornado.web.authenticated
|
|
15
17
|
def get(self, key: str) -> None:
|
|
16
|
-
value =
|
|
18
|
+
value: Optional[Any] = None
|
|
19
|
+
|
|
20
|
+
if key == "is_pro":
|
|
21
|
+
# Special case, since we don't store this key
|
|
22
|
+
# in the user.json file.
|
|
23
|
+
value = str(is_pro())
|
|
24
|
+
else:
|
|
25
|
+
value = get_user_field(key)
|
|
26
|
+
|
|
17
27
|
if value is None:
|
|
18
28
|
self.set_status(404)
|
|
19
29
|
self.finish(json.dumps({"error": f"User field with key '{key}' not found"}))
|
|
@@ -29,5 +39,7 @@ class UserHandler(APIHandler):
|
|
|
29
39
|
return
|
|
30
40
|
|
|
31
41
|
set_user_field(key, data["value"])
|
|
32
|
-
identify()
|
|
33
|
-
self.finish(
|
|
42
|
+
identify() # Log the new user
|
|
43
|
+
self.finish(
|
|
44
|
+
json.dumps({"status": "success", "key": key, "value": data["value"]})
|
|
45
|
+
)
|
mito_ai/utils/create.py
CHANGED
|
@@ -36,6 +36,17 @@ def is_user_json_exists_and_valid_json() -> bool:
|
|
|
36
36
|
except:
|
|
37
37
|
return False
|
|
38
38
|
|
|
39
|
+
def get_temp_user_id() -> Optional[str]:
|
|
40
|
+
"""
|
|
41
|
+
Looks for a temporary user ID, generated by the desktop app.
|
|
42
|
+
"""
|
|
43
|
+
temp_user_id_path = os.path.join(MITO_FOLDER, 'temp_user_id.txt')
|
|
44
|
+
|
|
45
|
+
if os.path.exists(temp_user_id_path):
|
|
46
|
+
with open(temp_user_id_path, 'r') as f:
|
|
47
|
+
return f.read()
|
|
48
|
+
|
|
49
|
+
return None
|
|
39
50
|
|
|
40
51
|
def try_create_user_json_file() -> None:
|
|
41
52
|
|
|
@@ -50,7 +61,12 @@ def try_create_user_json_file() -> None:
|
|
|
50
61
|
with open(USER_JSON_PATH, 'w+') as f:
|
|
51
62
|
f.write(json.dumps(USER_JSON_DEFAULT))
|
|
52
63
|
|
|
53
|
-
#
|
|
64
|
+
# Next, look for a temp user id
|
|
65
|
+
temp_user_id = get_temp_user_id()
|
|
66
|
+
if temp_user_id:
|
|
67
|
+
set_user_field(UJ_STATIC_USER_ID, temp_user_id)
|
|
68
|
+
|
|
69
|
+
# Finally, we take special care to put all the testing/CI environments
|
|
54
70
|
# (e.g. Github actions) under one ID and email
|
|
55
71
|
if is_running_test():
|
|
56
72
|
set_user_field(UJ_STATIC_USER_ID, GITHUB_ACTION_ID)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Copyright (c) Saga Inc.
|
|
2
|
+
# Distributed under the terms of the GNU Affero General Public License v3.0 License.
|
|
3
|
+
|
|
4
|
+
from mito_ai.app_deploy.models import AppDeployError
|
|
5
|
+
|
|
6
|
+
class MitoAppError(Exception):
|
|
7
|
+
"""Exception raised for custom error in the application."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, message: str, error_code: int) -> None:
|
|
10
|
+
super().__init__(message)
|
|
11
|
+
self.message = message
|
|
12
|
+
self.error_code = error_code
|
|
13
|
+
|
|
14
|
+
class StreamlitPreviewError(MitoAppError):
|
|
15
|
+
def __str__(self) -> str:
|
|
16
|
+
return f"[PreviewError]: {self.message} (Error Code: {self.error_code})"
|
|
17
|
+
|
|
18
|
+
class StreamlitConversionError(MitoAppError):
|
|
19
|
+
def __str__(self) -> str:
|
|
20
|
+
return f"[ConversionError]: {self.message} (Error Code: {self.error_code})"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class StreamlitDeploymentError(MitoAppError):
|
|
24
|
+
"""Raised when a deployment operation fails."""
|
|
25
|
+
|
|
26
|
+
def __init__(self, error: AppDeployError):
|
|
27
|
+
self.error = error
|
|
28
|
+
self.error_type = error.error_type
|
|
29
|
+
self.message_id = getattr(error, "message_id", "ErrorMessageID")
|
|
30
|
+
self.error_code = getattr(error, "error_code", 500)
|
|
31
|
+
self.hint = getattr(error, "hint", "")
|
|
32
|
+
self.traceback = getattr(error, "traceback", "")
|
|
33
|
+
self.error_type = getattr(error, "error_type", "Error")
|
|
34
|
+
self.message = error.message
|
|
35
|
+
print(f"self_message: {self.message}")
|
|
36
|
+
super().__init__(self.message, self.error_code)
|
|
37
|
+
|
|
38
|
+
def __str__(self) -> str:
|
|
39
|
+
base = f"[DeploymentError]: {self.message} (Error Code: {self.error_code})"
|
|
40
|
+
if self.hint:
|
|
41
|
+
base += f"\nHint: {self.hint}"
|
|
42
|
+
return base
|
|
@@ -10,6 +10,7 @@ from mito_ai.completions.prompt_builders.prompt_constants import (
|
|
|
10
10
|
ACTIVE_CELL_OUTPUT_SECTION_HEADING,
|
|
11
11
|
GET_CELL_OUTPUT_TOOL_RESPONSE_SECTION_HEADING,
|
|
12
12
|
FILES_SECTION_HEADING,
|
|
13
|
+
STREAMLIT_APP_STATUS_SECTION_HEADING,
|
|
13
14
|
VARIABLES_SECTION_HEADING,
|
|
14
15
|
JUPYTER_NOTEBOOK_SECTION_HEADING,
|
|
15
16
|
CONTENT_REMOVED_PLACEHOLDER
|
|
@@ -31,7 +32,8 @@ def trim_sections_from_message_content(content: str) -> str:
|
|
|
31
32
|
JUPYTER_NOTEBOOK_SECTION_HEADING,
|
|
32
33
|
GET_CELL_OUTPUT_TOOL_RESPONSE_SECTION_HEADING,
|
|
33
34
|
ACTIVE_CELL_OUTPUT_SECTION_HEADING,
|
|
34
|
-
ACTIVE_CELL_ID_SECTION_HEADING
|
|
35
|
+
ACTIVE_CELL_ID_SECTION_HEADING,
|
|
36
|
+
STREAMLIT_APP_STATUS_SECTION_HEADING
|
|
35
37
|
]
|
|
36
38
|
|
|
37
39
|
for heading in section_headings:
|
mito_ai/utils/telemetry_utils.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
5
|
import os
|
|
6
|
-
from typing import Any, Dict, Literal, Optional
|
|
6
|
+
from typing import Any, Dict, Literal, Optional, List
|
|
7
7
|
from mito_ai.utils.version_utils import MITOSHEET_HELPER_PRIVATE, is_pro
|
|
8
8
|
from mito_ai.utils.schema import UJ_AI_MITO_API_NUM_USAGES, UJ_MITOSHEET_TELEMETRY, UJ_STATIC_USER_ID, UJ_USER_EMAIL, UJ_FEEDBACKS_V2
|
|
9
9
|
from mito_ai.utils.db import get_user_field
|
|
@@ -190,7 +190,24 @@ def log(
|
|
|
190
190
|
|
|
191
191
|
if thread_id is not None:
|
|
192
192
|
final_params['thread_id'] = thread_id
|
|
193
|
-
|
|
193
|
+
|
|
194
|
+
# Process parameters that need chunking
|
|
195
|
+
params_to_remove = []
|
|
196
|
+
params_to_add = {}
|
|
197
|
+
|
|
198
|
+
for param_name, param_value in final_params.items():
|
|
199
|
+
if isinstance(param_value, str) and len(param_value) > 250:
|
|
200
|
+
# Mark for removal
|
|
201
|
+
params_to_remove.append(param_name)
|
|
202
|
+
# Get chunked parameters
|
|
203
|
+
chunked_params = chunk_param(param_value, param_name)
|
|
204
|
+
params_to_add.update(chunked_params)
|
|
205
|
+
|
|
206
|
+
# Apply the changes
|
|
207
|
+
for param_name in params_to_remove:
|
|
208
|
+
del final_params[param_name]
|
|
209
|
+
final_params.update(params_to_add)
|
|
210
|
+
|
|
194
211
|
# Finally, do the acutal logging. We do not log anything when tests are
|
|
195
212
|
# running, or if telemetry is turned off
|
|
196
213
|
if not is_running_test() and telemetry_turned_on(key_type):
|
|
@@ -383,33 +400,81 @@ def log_mito_server_free_tier_limit_reached(key_type: Literal['mito_server_key',
|
|
|
383
400
|
|
|
384
401
|
|
|
385
402
|
#################################
|
|
386
|
-
# Streamlit
|
|
403
|
+
# Streamlit Logs
|
|
387
404
|
#################################
|
|
388
405
|
|
|
389
|
-
|
|
406
|
+
###
|
|
407
|
+
# Converting Notebook into Streamlit App code
|
|
408
|
+
###
|
|
409
|
+
|
|
410
|
+
def log_streamlit_app_conversion_success(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, edit_prompt: str) -> None:
|
|
390
411
|
log(
|
|
391
|
-
"
|
|
412
|
+
"mito_ai_streamlit_app_conversion_success",
|
|
392
413
|
key_type=key_type,
|
|
393
414
|
params={
|
|
394
415
|
"edit_prompt": edit_prompt,
|
|
416
|
+
"message_type": message_type
|
|
395
417
|
}
|
|
396
418
|
)
|
|
397
419
|
|
|
398
|
-
def
|
|
420
|
+
def log_streamlit_app_validation_retry(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, error: List[str]) -> None:
|
|
399
421
|
log(
|
|
400
|
-
"
|
|
422
|
+
"mito_ai_streamlit_app_conversion_retry",
|
|
401
423
|
params={
|
|
402
424
|
"error_message": error,
|
|
425
|
+
"message_type": message_type
|
|
403
426
|
},
|
|
404
427
|
key_type=key_type
|
|
405
428
|
)
|
|
406
429
|
|
|
407
|
-
def
|
|
430
|
+
def log_streamlit_app_conversion_error(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, error_message: str, formatted_traceback: str, edit_prompt: str) -> None:
|
|
408
431
|
log(
|
|
409
|
-
"
|
|
432
|
+
"mito_ai_streamlit_app_conversion_error",
|
|
410
433
|
params={
|
|
411
|
-
"error_message":
|
|
434
|
+
"error_message": error_message,
|
|
435
|
+
"traceback": formatted_traceback,
|
|
412
436
|
"edit_prompt": edit_prompt,
|
|
437
|
+
"message_type": message_type
|
|
413
438
|
},
|
|
414
439
|
key_type=key_type
|
|
415
440
|
)
|
|
441
|
+
|
|
442
|
+
###
|
|
443
|
+
# Setting up Preview
|
|
444
|
+
###
|
|
445
|
+
|
|
446
|
+
def log_streamlit_app_preview_success(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, edit_prompt: str) -> None:
|
|
447
|
+
log(
|
|
448
|
+
"mito_ai_streamlit_app_preview_success",
|
|
449
|
+
key_type=key_type,
|
|
450
|
+
params={
|
|
451
|
+
"edit_prompt": edit_prompt,
|
|
452
|
+
"message_type": message_type
|
|
453
|
+
}
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
def log_streamlit_app_preview_failure(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, error_message: str, formatted_traceback: str, edit_prompt: str) -> None:
|
|
457
|
+
log(
|
|
458
|
+
"mito_ai_streamlit_app_preview_failure",
|
|
459
|
+
key_type=key_type,
|
|
460
|
+
params={
|
|
461
|
+
"error_message": error_message,
|
|
462
|
+
"traceback": formatted_traceback,
|
|
463
|
+
"message_type": message_type,
|
|
464
|
+
"edit_prompt": edit_prompt
|
|
465
|
+
}
|
|
466
|
+
)
|
|
467
|
+
|
|
468
|
+
###
|
|
469
|
+
# Deploying Streamlit App
|
|
470
|
+
###
|
|
471
|
+
|
|
472
|
+
def log_streamlit_app_deployment_failure(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, error: Dict) -> None:
|
|
473
|
+
log(
|
|
474
|
+
"mito_ai_streamlit_app_deployment_failure",
|
|
475
|
+
key_type=key_type,
|
|
476
|
+
params={
|
|
477
|
+
"error": error, # Contains all details in app_deploy.models.AppDeployError class
|
|
478
|
+
"message_type": message_type
|
|
479
|
+
}
|
|
480
|
+
)
|
{mito_ai-0.1.46.data → mito_ai-0.1.47.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.47",
|
|
4
4
|
"description": "AI chat for JupyterLab",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"outputDir": "mito_ai/labextension",
|
|
141
141
|
"schemaDir": "schema",
|
|
142
142
|
"_build": {
|
|
143
|
-
"load": "static/remoteEntry.
|
|
143
|
+
"load": "static/remoteEntry.e22c6cd4e56c32116daa.js",
|
|
144
144
|
"extension": "./extension",
|
|
145
145
|
"style": "./style"
|
|
146
146
|
}
|