mito-ai-core 0.1.1__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.
- mito_ai_core-0.1.1/.gitignore +139 -0
- mito_ai_core-0.1.1/PKG-INFO +117 -0
- mito_ai_core-0.1.1/README.md +81 -0
- mito_ai_core-0.1.1/mito_ai_core/__init__.py +11 -0
- mito_ai_core-0.1.1/mito_ai_core/_version.py +7 -0
- mito_ai_core-0.1.1/mito_ai_core/agent/__init__.py +25 -0
- mito_ai_core-0.1.1/mito_ai_core/agent/agent_runner.py +364 -0
- mito_ai_core-0.1.1/mito_ai_core/agent/agent_runner_config.py +26 -0
- mito_ai_core-0.1.1/mito_ai_core/agent/tool_executor.py +189 -0
- mito_ai_core-0.1.1/mito_ai_core/agent/types.py +133 -0
- mito_ai_core-0.1.1/mito_ai_core/agent/utils.py +156 -0
- mito_ai_core-0.1.1/mito_ai_core/app_deploy/__init__.py +8 -0
- mito_ai_core-0.1.1/mito_ai_core/app_deploy/models.py +98 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/__init__.py +11 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/anthropic_client.py +344 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/anthropic_utils.py +194 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/copilot_client.py +150 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/copilot_utils.py +209 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/gemini_client.py +225 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/gemini_utils.py +137 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/open_ai_utils.py +219 -0
- mito_ai_core-0.1.1/mito_ai_core/clients/openai_client.py +306 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/ai_optimized_message.py +87 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/message_history.py +405 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/models.py +428 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/__init__.py +3 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/agent_execution_prompt.py +26 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/agent_system_message.py +569 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/agent_tool_result_prompt.py +57 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/chart_add_field_prompt.py +35 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/chart_conversion_prompt.py +27 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/chat_name_prompt.py +15 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/chat_prompt.py +35 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/chat_system_message.py +178 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/excel_to_python_rules.py +122 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/explain_code_prompt.py +30 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/inline_completer_prompt.py +170 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_constants.py +219 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/__init__.py +70 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/active_cell_code.py +15 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/active_cell_id.py +15 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/active_cell_output.py +20 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/base.py +61 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/error_traceback.py +17 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/example.py +19 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/files.py +22 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/generic.py +15 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/get_cell_output_tool_response.py +21 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/notebook.py +36 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/rules.py +39 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/selected_context.py +111 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/streamlit_app_status.py +25 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/task.py +12 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/prompt_section_registry/variables.py +38 -0
- mito_ai_core-0.1.1/mito_ai_core/completions/prompt_builders/smart_debug_prompt.py +186 -0
- mito_ai_core-0.1.1/mito_ai_core/constants.py +89 -0
- mito_ai_core-0.1.1/mito_ai_core/copilot/__init__.py +4 -0
- mito_ai_core-0.1.1/mito_ai_core/copilot/model_ids.py +30 -0
- mito_ai_core-0.1.1/mito_ai_core/copilot/service.py +473 -0
- mito_ai_core-0.1.1/mito_ai_core/enterprise/__init__.py +3 -0
- mito_ai_core-0.1.1/mito_ai_core/enterprise/litellm_client.py +144 -0
- mito_ai_core-0.1.1/mito_ai_core/enterprise/utils.py +29 -0
- mito_ai_core-0.1.1/mito_ai_core/kernel_variable_inspection.py +15 -0
- mito_ai_core-0.1.1/mito_ai_core/logger.py +21 -0
- mito_ai_core-0.1.1/mito_ai_core/path_utils.py +70 -0
- mito_ai_core-0.1.1/mito_ai_core/provider_manager.py +522 -0
- mito_ai_core-0.1.1/mito_ai_core/py.typed +0 -0
- mito_ai_core-0.1.1/mito_ai_core/resources/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/resources/kernel_variable_inspection.txt +140 -0
- mito_ai_core-0.1.1/mito_ai_core/rules/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/rules/utils.py +220 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/agent/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/agent/test_agent_runner.py +741 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/agent/test_agent_utils.py +109 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/agent/test_tool_executor.py +306 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/completions/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/completions/test_prompt_section_registry.py +125 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/create_agent_system_message_prompt_test.py +22 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/data/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/data/prompt_lg.py +69 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/data/prompt_sm.py +6 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/data/prompt_xl.py +13 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/message_history/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/message_history/test_generate_short_chat_name.py +189 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/message_history/test_message_history_utils.py +402 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/open_ai_utils_test.py +166 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_anthropic_client.py +609 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_capabilities.py +107 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_gemini_client.py +195 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_mito_server_utils.py +447 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_model_resolution.py +177 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_openai_client.py +252 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_provider_completion_exception.py +66 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_provider_limits.py +33 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_providers.py +543 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_retry_logic.py +364 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/test_stream_mito_server_utils.py +140 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/providers/utils.py +86 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/server_limits_test.py +406 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/test_constants.py +137 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/test_enterprise_mode.py +207 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/test_kernel_variable_inspection.py +13 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/test_model_utils.py +398 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/utils/__init__.py +2 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/utils/test_anthropic_utils.py +162 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/utils/test_gemini_utils.py +141 -0
- mito_ai_core-0.1.1/mito_ai_core/tests/utils/test_provider_utils.py +12 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/__init__.py +3 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/create.py +94 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/db.py +74 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/error_classes.py +42 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/litellm_utils.py +84 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/message_history_utils.py +40 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/mito_server_utils.py +222 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/model_utils.py +283 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/provider_utils.py +42 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/schema.py +86 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/server_limits.py +152 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/telemetry_utils.py +492 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/token_usage_logger.py +60 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/tokens.py +33 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/trim_message_history.py +125 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/utils.py +88 -0
- mito_ai_core-0.1.1/mito_ai_core/utils/version_utils.py +108 -0
- mito_ai_core-0.1.1/pyproject.toml +62 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Ignore the uv.lock file that Cursor keeps making
|
|
2
|
+
uv.lock
|
|
3
|
+
|
|
4
|
+
# Ignore all the ipynb files in mitosheet and mito-ai
|
|
5
|
+
mitosheet/**/*.ipynb
|
|
6
|
+
mito-ai/**/*.ipynb
|
|
7
|
+
|
|
8
|
+
# Ignore all the ipynb_checkpoints in mitosheet and mito-ai
|
|
9
|
+
mitosheet/.ipynb_checkpoints/*
|
|
10
|
+
mito-ai/.ipynb_checkpoints/*
|
|
11
|
+
tests/.ipynb_checkpoints/*
|
|
12
|
+
jupyterhub/.ipynb_checkpoints/*
|
|
13
|
+
.ipynb_checkpoints/*
|
|
14
|
+
|
|
15
|
+
# Ignore all the iframe_figures in mitosheet and mito-ai
|
|
16
|
+
# These get generated when creating plotly graphs
|
|
17
|
+
mitosheet/iframe_figures/*
|
|
18
|
+
mito-ai/iframe_figures/*
|
|
19
|
+
mito-sql-cell
|
|
20
|
+
|
|
21
|
+
# Evals
|
|
22
|
+
evals/reports/
|
|
23
|
+
|
|
24
|
+
# Other
|
|
25
|
+
mito-ai-mcp/*.mcpb
|
|
26
|
+
|
|
27
|
+
## General
|
|
28
|
+
.DS_Store
|
|
29
|
+
.AppleDouble
|
|
30
|
+
.LSOverride
|
|
31
|
+
.env
|
|
32
|
+
|
|
33
|
+
## Icon must end with two \r
|
|
34
|
+
Icon
|
|
35
|
+
|
|
36
|
+
## Thumbnails
|
|
37
|
+
._*
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## Files that might appear in the root of a volume
|
|
41
|
+
.DocumentRevisions-V100
|
|
42
|
+
.fseventsd
|
|
43
|
+
.Spotlight-V100
|
|
44
|
+
.TemporaryItems
|
|
45
|
+
.Trashes
|
|
46
|
+
.VolumeIcon.icns
|
|
47
|
+
.com.apple.timemachine.donotpresent
|
|
48
|
+
|
|
49
|
+
## Directories potentially created on remote AFP share
|
|
50
|
+
.AppleDB
|
|
51
|
+
.AppleDesktop
|
|
52
|
+
Network Trash Folder
|
|
53
|
+
Temporary Items
|
|
54
|
+
.apdisk
|
|
55
|
+
|
|
56
|
+
# Windows
|
|
57
|
+
|
|
58
|
+
## Windows thumbnail cache files
|
|
59
|
+
Thumbs.db
|
|
60
|
+
Thumbs.db:encryptable
|
|
61
|
+
ehthumbs.db
|
|
62
|
+
ehthumbs_vista.db
|
|
63
|
+
|
|
64
|
+
## Dump file
|
|
65
|
+
*.stackdump
|
|
66
|
+
|
|
67
|
+
## Folder config file
|
|
68
|
+
[Dd]esktop.ini
|
|
69
|
+
|
|
70
|
+
## Recycle Bin used on file shares
|
|
71
|
+
$RECYCLE.BIN/
|
|
72
|
+
|
|
73
|
+
## Windows Installer files
|
|
74
|
+
*.cab
|
|
75
|
+
*.msi
|
|
76
|
+
*.msix
|
|
77
|
+
*.msm
|
|
78
|
+
*.msp
|
|
79
|
+
|
|
80
|
+
## Windows shortcuts
|
|
81
|
+
*.lnk
|
|
82
|
+
|
|
83
|
+
## Python
|
|
84
|
+
|
|
85
|
+
# Virtual enviornemnts
|
|
86
|
+
venv/
|
|
87
|
+
|
|
88
|
+
# Byte-compiled / optimized / DLL files
|
|
89
|
+
__pycache__/
|
|
90
|
+
*.py[cod]
|
|
91
|
+
|
|
92
|
+
# C extensions
|
|
93
|
+
*.so
|
|
94
|
+
|
|
95
|
+
# Distribution / packaging
|
|
96
|
+
bin/
|
|
97
|
+
build/
|
|
98
|
+
develop-eggs/
|
|
99
|
+
dist/
|
|
100
|
+
eggs/
|
|
101
|
+
lib/
|
|
102
|
+
lib64/
|
|
103
|
+
parts/
|
|
104
|
+
sdist/
|
|
105
|
+
var/
|
|
106
|
+
*.egg-info/
|
|
107
|
+
.installed.cfg
|
|
108
|
+
*.egg
|
|
109
|
+
node_modules/
|
|
110
|
+
|
|
111
|
+
# Installer logs
|
|
112
|
+
pip-log.txt
|
|
113
|
+
pip-delete-this-directory.txt
|
|
114
|
+
|
|
115
|
+
# Unit test / coverage reports
|
|
116
|
+
.tox/
|
|
117
|
+
.coverage
|
|
118
|
+
.cache
|
|
119
|
+
nosetests.xml
|
|
120
|
+
coverage.xml
|
|
121
|
+
|
|
122
|
+
# Translations
|
|
123
|
+
*.mo
|
|
124
|
+
|
|
125
|
+
# Mr Developer
|
|
126
|
+
.mr.developer.cfg
|
|
127
|
+
.project
|
|
128
|
+
.pydevproject
|
|
129
|
+
|
|
130
|
+
# Rope
|
|
131
|
+
.ropeproject
|
|
132
|
+
|
|
133
|
+
# Django stuff:
|
|
134
|
+
*.log
|
|
135
|
+
*.pot
|
|
136
|
+
|
|
137
|
+
# Sphinx documentation
|
|
138
|
+
docs/_build/
|
|
139
|
+
mito-sql-cell/junit.xml
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mito-ai-core
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Pure-Python AI backbone for Mito – providers, models, prompts, and utilities with zero Jupyter Server dependencies.
|
|
5
|
+
Author: Saga Inc.
|
|
6
|
+
License-Expression: AGPL-3.0-only
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Requires-Dist: aiohttp>=3.8.0
|
|
18
|
+
Requires-Dist: analytics-python
|
|
19
|
+
Requires-Dist: anthropic>=0.6.81
|
|
20
|
+
Requires-Dist: google-genai
|
|
21
|
+
Requires-Dist: jinja2>=3.0.3
|
|
22
|
+
Requires-Dist: openai>=1.0.0
|
|
23
|
+
Requires-Dist: pydantic
|
|
24
|
+
Requires-Dist: requests>=2.25.0
|
|
25
|
+
Requires-Dist: sseclient-py>=1.8.0
|
|
26
|
+
Requires-Dist: tornado>=6.2.0
|
|
27
|
+
Provides-Extra: litellm
|
|
28
|
+
Requires-Dist: litellm; extra == 'litellm'
|
|
29
|
+
Provides-Extra: test
|
|
30
|
+
Requires-Dist: mypy; extra == 'test'
|
|
31
|
+
Requires-Dist: pytest; extra == 'test'
|
|
32
|
+
Requires-Dist: pytest-asyncio; extra == 'test'
|
|
33
|
+
Requires-Dist: pytest-timeout; extra == 'test'
|
|
34
|
+
Requires-Dist: types-requests; extra == 'test'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# mito-ai-core
|
|
38
|
+
|
|
39
|
+
The shared Python AI layer for Mito -- LLM providers, models, prompts, and utils. No Jupyter Server or Tornado dependency.
|
|
40
|
+
|
|
41
|
+
`mito-ai` (the JupyterLab extension) depends on this package for all its AI logic. If you're building something else on top of Mito's AI stack, this is the package you want.
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install mito-ai-core
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Development
|
|
50
|
+
|
|
51
|
+
### Working on mito-ai-core only
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cd mito-ai-core
|
|
55
|
+
pip install -e ".[test]"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Working on both mito-ai-core and mito-ai at the same time
|
|
59
|
+
|
|
60
|
+
Install both packages in editable mode so changes in either package are picked up immediately without reinstalling:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# From the repo root
|
|
64
|
+
pip install -e ./mito-ai-core
|
|
65
|
+
pip install -e "./mito-ai[test]"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Order matters!** Install `mito-ai-core` first since `mito-ai` depends on it. After this, any change you make to a `.py` file in either package takes effect on the next import (no rebuild needed).
|
|
69
|
+
|
|
70
|
+
### How it relates to mito-ai
|
|
71
|
+
|
|
72
|
+
`mito-ai-core` contains all the pure-Python AI logic -- providers, models, prompts, message history, utils.
|
|
73
|
+
|
|
74
|
+
`mito-ai` is the JupyterLab extension that adds WebSocket/REST handlers, UI integration, and Streamlit conversion on top of it.
|
|
75
|
+
|
|
76
|
+
If you're changing provider logic, prompt templates, or models, you're working here. If you're changing how the extension talks to the frontend or handles HTTP requests, you're working in `mito-ai`.
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
Everything goes through `ProviderManager`:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from mito_ai_core.provider_manager import ProviderManager
|
|
84
|
+
from mito_ai_core.completions.models import MessageType
|
|
85
|
+
|
|
86
|
+
pm = ProviderManager()
|
|
87
|
+
pm.set_selected_model("gpt-4.1")
|
|
88
|
+
|
|
89
|
+
# One-shot
|
|
90
|
+
response = await pm.request_completions(
|
|
91
|
+
message_type=MessageType.CHAT,
|
|
92
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Streaming -- pass a callback
|
|
96
|
+
response = await pm.stream_completions(
|
|
97
|
+
message_type=MessageType.CHAT,
|
|
98
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
99
|
+
message_id="msg-1",
|
|
100
|
+
thread_id="thread-1",
|
|
101
|
+
reply_fn=lambda chunk: print(chunk),
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`ProviderManager` picks the right client (OpenAI, Anthropic, Gemini, Copilot, LiteLLM, Abacus) based on the selected model. It handles retries, telemetry, and token logging.
|
|
106
|
+
|
|
107
|
+
This is a library, not a server. The caller owns the transport (WebSocket, HTTP, CLI, whatever).
|
|
108
|
+
|
|
109
|
+
## Key modules
|
|
110
|
+
|
|
111
|
+
- **`provider_manager`** -- routes requests to the right LLM client
|
|
112
|
+
- **`clients/`** -- OpenAI, Anthropic, Gemini, Copilot wrappers
|
|
113
|
+
- **`completions/models`** -- all the dataclasses and Pydantic models
|
|
114
|
+
- **`completions/message_history`** -- thread-safe chat persistence
|
|
115
|
+
- **`completions/prompt_builders/`** -- prompt construction for chat, agent, debug, inline completion, charts
|
|
116
|
+
- **`utils/`** -- model resolution, token estimation, telemetry, rate limits
|
|
117
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# mito-ai-core
|
|
2
|
+
|
|
3
|
+
The shared Python AI layer for Mito -- LLM providers, models, prompts, and utils. No Jupyter Server or Tornado dependency.
|
|
4
|
+
|
|
5
|
+
`mito-ai` (the JupyterLab extension) depends on this package for all its AI logic. If you're building something else on top of Mito's AI stack, this is the package you want.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install mito-ai-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
### Working on mito-ai-core only
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
cd mito-ai-core
|
|
19
|
+
pip install -e ".[test]"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Working on both mito-ai-core and mito-ai at the same time
|
|
23
|
+
|
|
24
|
+
Install both packages in editable mode so changes in either package are picked up immediately without reinstalling:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# From the repo root
|
|
28
|
+
pip install -e ./mito-ai-core
|
|
29
|
+
pip install -e "./mito-ai[test]"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Order matters!** Install `mito-ai-core` first since `mito-ai` depends on it. After this, any change you make to a `.py` file in either package takes effect on the next import (no rebuild needed).
|
|
33
|
+
|
|
34
|
+
### How it relates to mito-ai
|
|
35
|
+
|
|
36
|
+
`mito-ai-core` contains all the pure-Python AI logic -- providers, models, prompts, message history, utils.
|
|
37
|
+
|
|
38
|
+
`mito-ai` is the JupyterLab extension that adds WebSocket/REST handlers, UI integration, and Streamlit conversion on top of it.
|
|
39
|
+
|
|
40
|
+
If you're changing provider logic, prompt templates, or models, you're working here. If you're changing how the extension talks to the frontend or handles HTTP requests, you're working in `mito-ai`.
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
Everything goes through `ProviderManager`:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from mito_ai_core.provider_manager import ProviderManager
|
|
48
|
+
from mito_ai_core.completions.models import MessageType
|
|
49
|
+
|
|
50
|
+
pm = ProviderManager()
|
|
51
|
+
pm.set_selected_model("gpt-4.1")
|
|
52
|
+
|
|
53
|
+
# One-shot
|
|
54
|
+
response = await pm.request_completions(
|
|
55
|
+
message_type=MessageType.CHAT,
|
|
56
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Streaming -- pass a callback
|
|
60
|
+
response = await pm.stream_completions(
|
|
61
|
+
message_type=MessageType.CHAT,
|
|
62
|
+
messages=[{"role": "user", "content": "Hello!"}],
|
|
63
|
+
message_id="msg-1",
|
|
64
|
+
thread_id="thread-1",
|
|
65
|
+
reply_fn=lambda chunk: print(chunk),
|
|
66
|
+
)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`ProviderManager` picks the right client (OpenAI, Anthropic, Gemini, Copilot, LiteLLM, Abacus) based on the selected model. It handles retries, telemetry, and token logging.
|
|
70
|
+
|
|
71
|
+
This is a library, not a server. The caller owns the transport (WebSocket, HTTP, CLI, whatever).
|
|
72
|
+
|
|
73
|
+
## Key modules
|
|
74
|
+
|
|
75
|
+
- **`provider_manager`** -- routes requests to the right LLM client
|
|
76
|
+
- **`clients/`** -- OpenAI, Anthropic, Gemini, Copilot wrappers
|
|
77
|
+
- **`completions/models`** -- all the dataclasses and Pydantic models
|
|
78
|
+
- **`completions/message_history`** -- thread-safe chat persistence
|
|
79
|
+
- **`completions/prompt_builders/`** -- prompt construction for chat, agent, debug, inline completion, charts
|
|
80
|
+
- **`utils/`** -- model resolution, token estimation, telemetry, rate limits
|
|
81
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copyright (c) Saga Inc.
|
|
2
|
+
# Distributed under the terms of the GNU Affero General Public License v3.0 License.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
mito-ai-core: Pure-Python AI backbone for Mito.
|
|
6
|
+
|
|
7
|
+
Providers, Pydantic models, prompt builders, message history, and utilities
|
|
8
|
+
with **zero** Jupyter Server / Tornado dependencies.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from mito_ai_core._version import __version__ # noqa: F401
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Copyright (c) Saga Inc.
|
|
2
|
+
# Distributed under the terms of the GNU Affero General Public License v3.0 License.
|
|
3
|
+
|
|
4
|
+
# This file is auto-generated by Hatchling. As such, do not:
|
|
5
|
+
# - modify
|
|
6
|
+
# - track in version control e.g. be sure to add to .gitignore
|
|
7
|
+
__version__ = VERSION = '0.1.228'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright (c) Saga Inc.
|
|
2
|
+
# Distributed under the terms of the GNU Affero General Public License v3.0 License.
|
|
3
|
+
|
|
4
|
+
"""Agent layer public types and protocols.
|
|
5
|
+
|
|
6
|
+
Import :class:`~mito_ai_core.agent.agent_runner.AgentRunner` from
|
|
7
|
+
``mito_ai_core.agent.agent_runner`` so this package's ``__init__`` does not
|
|
8
|
+
eagerly load the runner (which pulls in prompt builders and would create import
|
|
9
|
+
cycles with ``mito_ai_core.agent.types``).
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from mito_ai_core.agent.types import AgentContext, AgentRunResult, CompletionProvider, ToolResult
|
|
15
|
+
from mito_ai_core.agent.tool_executor import ToolExecutor
|
|
16
|
+
from mito_ai_core.completions.models import KernelVariable
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"AgentContext",
|
|
20
|
+
"KernelVariable",
|
|
21
|
+
"ToolResult",
|
|
22
|
+
"ToolExecutor",
|
|
23
|
+
"AgentRunResult",
|
|
24
|
+
"CompletionProvider",
|
|
25
|
+
]
|