Skip to main content

Pure-Python AI backbone for Mito – providers, models, prompts, and utilities with zero Jupyter Server dependencies.

Project description

mito-ai-core

The shared Python AI layer for Mito -- LLM providers, models, prompts, and utils. No Jupyter Server or Tornado dependency.

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.

Install

pip install mito-ai-core

Development

Working on mito-ai-core only

cd mito-ai-core
pip install -e ".[test]"

Working on both mito-ai-core and mito-ai at the same time

Install both packages in editable mode so changes in either package are picked up immediately without reinstalling:

# From the repo root
pip install -e ./mito-ai-core
pip install -e "./mito-ai[test]"

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).

How it relates to mito-ai

mito-ai-core contains all the pure-Python AI logic -- providers, models, prompts, message history, utils.

mito-ai is the JupyterLab extension that adds WebSocket/REST handlers, UI integration, and Streamlit conversion on top of it.

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.

Usage

Everything goes through ProviderManager:

from mito_ai_core.provider_manager import ProviderManager
from mito_ai_core.completions.models import MessageType

pm = ProviderManager()
pm.set_selected_model("gpt-4.1")

# One-shot
response = await pm.request_completions(
    message_type=MessageType.CHAT,
    messages=[{"role": "user", "content": "Hello!"}],
)

# Streaming -- pass a callback
response = await pm.stream_completions(
    message_type=MessageType.CHAT,
    messages=[{"role": "user", "content": "Hello!"}],
    message_id="msg-1",
    thread_id="thread-1",
    reply_fn=lambda chunk: print(chunk),
)

ProviderManager picks the right client (OpenAI, Anthropic, Gemini, Copilot, LiteLLM, Abacus) based on the selected model. It handles retries, telemetry, and token logging.

This is a library, not a server. The caller owns the transport (WebSocket, HTTP, CLI, whatever).

Key modules

  • provider_manager -- routes requests to the right LLM client
  • clients/ -- OpenAI, Anthropic, Gemini, Copilot wrappers
  • completions/models -- all the dataclasses and Pydantic models
  • completions/message_history -- thread-safe chat persistence
  • completions/prompt_builders/ -- prompt construction for chat, agent, debug, inline completion, charts
  • utils/ -- model resolution, token estimation, telemetry, rate limits

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mito_ai_core-0.1.2.tar.gz (148.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mito_ai_core-0.1.2-py3-none-any.whl (213.7 kB view details)

Uploaded Python 3

File details

Details for the file mito_ai_core-0.1.2.tar.gz.

File metadata

  • Download URL: mito_ai_core-0.1.2.tar.gz
  • Upload date:
  • Size: 148.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for mito_ai_core-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c0f12e7802b1af1e20fab3ca54f239e385cb2395faf07b65989c9984a1c3b35d
MD5 af3c55a0e3b8f3fa20e44b9160d7ba6e
BLAKE2b-256 daf1e78c8a8b46032b059aec352c330202af3d566d35d572b3478ca3c497e869

See more details on using hashes here.

File details

Details for the file mito_ai_core-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mito_ai_core-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 213.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for mito_ai_core-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7207f0b858453317451e31919a33550306e931ce70db8d5d15e0b01c2365cdd7
MD5 3fa88f5ed0c4d86cadb588f5be9d38cf
BLAKE2b-256 d4098eb08f90caa29c195f508e25cde13c497d36a1038c372397733c475fb6e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page