mito-ai 0.1.46__py3-none-any.whl → 0.1.48__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.

Files changed (72) hide show
  1. mito_ai/_version.py +1 -1
  2. mito_ai/app_deploy/handlers.py +98 -77
  3. mito_ai/app_deploy/models.py +16 -12
  4. mito_ai/completions/models.py +5 -1
  5. mito_ai/completions/prompt_builders/agent_execution_prompt.py +10 -1
  6. mito_ai/completions/prompt_builders/agent_system_message.py +63 -4
  7. mito_ai/completions/prompt_builders/chat_system_message.py +4 -0
  8. mito_ai/completions/prompt_builders/prompt_constants.py +1 -0
  9. mito_ai/completions/prompt_builders/utils.py +14 -0
  10. mito_ai/path_utils.py +56 -0
  11. mito_ai/streamlit_conversion/agent_utils.py +4 -201
  12. mito_ai/streamlit_conversion/prompts/prompt_constants.py +142 -152
  13. mito_ai/streamlit_conversion/prompts/streamlit_error_correction_prompt.py +3 -3
  14. mito_ai/streamlit_conversion/prompts/streamlit_finish_todo_prompt.py +2 -2
  15. mito_ai/streamlit_conversion/prompts/update_existing_app_prompt.py +2 -2
  16. mito_ai/streamlit_conversion/search_replace_utils.py +94 -0
  17. mito_ai/streamlit_conversion/streamlit_agent_handler.py +35 -46
  18. mito_ai/streamlit_conversion/streamlit_utils.py +12 -66
  19. mito_ai/streamlit_conversion/validate_streamlit_app.py +6 -21
  20. mito_ai/streamlit_preview/__init__.py +1 -2
  21. mito_ai/streamlit_preview/handlers.py +53 -85
  22. mito_ai/streamlit_preview/manager.py +7 -16
  23. mito_ai/streamlit_preview/utils.py +8 -28
  24. mito_ai/tests/message_history/test_message_history_utils.py +1 -0
  25. mito_ai/tests/streamlit_conversion/test_apply_search_replace.py +240 -0
  26. mito_ai/tests/streamlit_conversion/test_streamlit_agent_handler.py +39 -60
  27. mito_ai/tests/streamlit_conversion/test_streamlit_utils.py +26 -29
  28. mito_ai/tests/streamlit_conversion/test_validate_streamlit_app.py +25 -20
  29. mito_ai/tests/streamlit_preview/test_streamlit_preview_handler.py +81 -56
  30. mito_ai/tests/streamlit_preview/test_streamlit_preview_manager.py +24 -37
  31. mito_ai/user/handlers.py +15 -3
  32. mito_ai/utils/create.py +17 -1
  33. mito_ai/utils/error_classes.py +42 -0
  34. mito_ai/utils/message_history_utils.py +3 -1
  35. mito_ai/utils/telemetry_utils.py +78 -13
  36. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/build_log.json +100 -100
  37. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/package.json +2 -2
  38. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/schemas/mito_ai/package.json.orig +1 -1
  39. mito_ai-0.1.46.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.20f12766ecd3d430568e.js → mito_ai-0.1.48.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.5c7d84a45ddeb5704b61.js +1515 -449
  40. mito_ai-0.1.48.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.5c7d84a45ddeb5704b61.js.map +1 -0
  41. mito_ai-0.1.46.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.54126ab6511271265443.js → mito_ai-0.1.48.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.045d65d1de6fde3f3b72.js +18 -18
  42. mito_ai-0.1.46.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.54126ab6511271265443.js.map → mito_ai-0.1.48.data/data/share/jupyter/labextensions/mito_ai/static/remoteEntry.045d65d1de6fde3f3b72.js.map +1 -1
  43. {mito_ai-0.1.46.dist-info → mito_ai-0.1.48.dist-info}/METADATA +1 -1
  44. {mito_ai-0.1.46.dist-info → mito_ai-0.1.48.dist-info}/RECORD +69 -67
  45. mito_ai/tests/streamlit_conversion/test_apply_patch_to_text.py +0 -368
  46. mito_ai/tests/streamlit_conversion/test_fix_diff_headers.py +0 -533
  47. mito_ai-0.1.46.data/data/share/jupyter/labextensions/mito_ai/static/lib_index_js.20f12766ecd3d430568e.js.map +0 -1
  48. /mito_ai/streamlit_conversion/{streamlit_system_prompt.py → prompts/streamlit_system_prompt.py} +0 -0
  49. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/etc/jupyter/jupyter_server_config.d/mito_ai.json +0 -0
  50. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/schemas/mito_ai/toolbar-buttons.json +0 -0
  51. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/node_modules_process_browser_js.4b128e94d31a81ebd209.js +0 -0
  52. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/node_modules_process_browser_js.4b128e94d31a81ebd209.js.map +0 -0
  53. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/style.js +0 -0
  54. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/style_index_js.5876024bb17dbd6a3ee6.js +0 -0
  55. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/style_index_js.5876024bb17dbd6a3ee6.js.map +0 -0
  56. {mito_ai-0.1.46.data → mito_ai-0.1.48.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
  57. {mito_ai-0.1.46.data → mito_ai-0.1.48.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
  58. {mito_ai-0.1.46.data → mito_ai-0.1.48.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
  59. {mito_ai-0.1.46.data → mito_ai-0.1.48.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
  60. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_dist_esm_index_mjs.6bac1a8c4cc93f15f6b7.js +0 -0
  61. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_dist_esm_index_mjs.6bac1a8c4cc93f15f6b7.js.map +0 -0
  62. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_ui-react_dist_esm_index_mjs.4fcecd65bef9e9847609.js +0 -0
  63. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_aws-amplify_ui-react_dist_esm_index_mjs.4fcecd65bef9e9847609.js.map +0 -0
  64. {mito_ai-0.1.46.data → mito_ai-0.1.48.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
  65. {mito_ai-0.1.46.data → mito_ai-0.1.48.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
  66. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_semver_index_js.3f6754ac5116d47de76b.js +0 -0
  67. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_semver_index_js.3f6754ac5116d47de76b.js.map +0 -0
  68. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_vscode-diff_dist_index_js.ea55f1f9346638aafbcf.js +0 -0
  69. {mito_ai-0.1.46.data → mito_ai-0.1.48.data}/data/share/jupyter/labextensions/mito_ai/static/vendors-node_modules_vscode-diff_dist_index_js.ea55f1f9346638aafbcf.js.map +0 -0
  70. {mito_ai-0.1.46.dist-info → mito_ai-0.1.48.dist-info}/WHEEL +0 -0
  71. {mito_ai-0.1.46.dist-info → mito_ai-0.1.48.dist-info}/entry_points.txt +0 -0
  72. {mito_ai-0.1.46.dist-info → mito_ai-0.1.48.dist-info}/licenses/LICENSE +0 -0
@@ -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):
@@ -368,7 +385,7 @@ def log_file_upload_failure(error: str) -> None:
368
385
  log("mito_ai_file_upload_failure", params={"error_message": error})
369
386
 
370
387
  def log_ai_completion_retry(key_type: Literal['mito_server_key', 'user_key'], thread_id: str, message_type: MessageType, error: BaseException) -> None:
371
- log(MITO_AI_COMPLETION_RETRY, params={KEY_TYPE_PARAM: key_type, "message_type": message_type}, thread_id=thread_id, key_type=key_type, error=error)
388
+ log(MITO_AI_COMPLETION_RETRY, params={KEY_TYPE_PARAM: key_type, "message_type": message_type.value}, thread_id=thread_id, key_type=key_type, error=error)
372
389
 
373
390
  def log_ai_completion_error(
374
391
  key_type: Literal['mito_server_key', 'user_key'],
@@ -376,40 +393,88 @@ def log_ai_completion_error(
376
393
  message_type: MessageType,
377
394
  error: BaseException
378
395
  ) -> None:
379
- log(MITO_AI_COMPLETION_ERROR, params={KEY_TYPE_PARAM: key_type, "message_type": message_type}, thread_id=thread_id, key_type=key_type, error=error)
396
+ log(MITO_AI_COMPLETION_ERROR, params={KEY_TYPE_PARAM: key_type, "message_type": message_type.value}, thread_id=thread_id, key_type=key_type, error=error)
380
397
 
381
398
  def log_mito_server_free_tier_limit_reached(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType) -> None:
382
- log(MITO_SERVER_FREE_TIER_LIMIT_REACHED, params={KEY_TYPE_PARAM: key_type, "message_type": message_type}, key_type=key_type)
399
+ log(MITO_SERVER_FREE_TIER_LIMIT_REACHED, params={KEY_TYPE_PARAM: key_type, "message_type": message_type.value}, key_type=key_type)
383
400
 
384
401
 
385
402
  #################################
386
- # Streamlit Conversion
403
+ # Streamlit Logs
387
404
  #################################
388
405
 
389
- def log_streamlit_app_creation_success(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, edit_prompt: str) -> None:
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
- "mito_ai_streamlit_app_creation_success",
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.value
395
417
  }
396
418
  )
397
419
 
398
- def log_streamlit_app_creation_retry(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, error: str) -> None:
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
- "mito_ai_streamlit_app_creation_retry",
422
+ "mito_ai_streamlit_app_conversion_retry",
401
423
  params={
402
424
  "error_message": error,
425
+ "message_type": message_type.value
403
426
  },
404
427
  key_type=key_type
405
428
  )
406
429
 
407
- def log_streamlit_app_creation_error(key_type: Literal['mito_server_key', 'user_key'], message_type: MessageType, error: str, edit_prompt: str) -> None:
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
- "mito_ai_streamlit_app_creation_error",
432
+ "mito_ai_streamlit_app_conversion_error",
410
433
  params={
411
- "error_message": error,
434
+ "error_message": error_message,
435
+ "traceback": formatted_traceback,
412
436
  "edit_prompt": edit_prompt,
437
+ "message_type": message_type.value
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.value
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.value,
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.value
479
+ }
480
+ )