Skip to main content

Customizable code editor widget for marimo with pluggable execution backends

Project description

Ontonaut ๐Ÿš€

Python Version License: MIT Code style: black

Interactive widgets for marimo with pluggable backends

Ontonaut provides beautiful, marimo-compatible widgets for code execution and AI chat with customizable backends. Build domain-specific languages, create custom interpreters, or integrate AI assistants - all within your marimo notebooks!

โœจ Features

CodeEditor Widget

  • ๐ŸŽจ Clean, marimo-style UI - Seamless integration with marimo's aesthetic
  • ๐Ÿ”Œ Pluggable executors - Python, JSON, Calculator, Regex, or your own
  • ๐Ÿ› ๏ธ Custom languages - Create DSLs and custom interpreters
  • โŒจ๏ธ Keyboard shortcuts - Cmd/Ctrl+Enter to run
  • ๐ŸŒ“ Light & dark themes - Follows your marimo theme

ChatBot Widget

  • ๐Ÿ’ฌ Streaming responses - Real-time, token-by-token output
  • ๐Ÿ“‘ Automatic tabs - Each question creates a new history tab
  • ๐Ÿ’ป Code formatting - Markdown code blocks render beautifully
  • ๐Ÿค– Multiple handlers - OpenAI, Anthropic, MCP, or custom
  • ๐ŸŽฏ Type-safe - Full type hints throughout

๐Ÿ“ฆ Installation

pip install ontonaut

๐Ÿš€ Quick Start

CodeEditor

import marimo as mo
from ontonaut import CodeEditor, PythonExecutor

editor = CodeEditor(
    executor=PythonExecutor(),
    code="x = 10\nresult = x * 2",
    theme="dark"
)
editor

ChatBot

from ontonaut import ChatBot, EchoHandler

chatbot = ChatBot(
    handler=EchoHandler(),
    placeholder="Ask me anything...",
    theme="dark"
)
chatbot

๐Ÿ“š Documentation

๐Ÿ“– User Guides

Comprehensive guides for using Ontonaut:

๐Ÿ““ Interactive Notebooks

Runnable marimo notebooks with examples:

Run them:

marimo edit book/marimo/01-getting-started.py

๐Ÿ—๏ธ Architecture Docs

For developers and AI assistants:

๐Ÿ’ก Examples

Custom DSL

from ontonaut import CodeEditor

def greeting_dsl(code: str) -> str:
    """Simple greeting DSL."""
    lines = code.strip().split("\n")
    results = []

    for line in lines:
        parts = line.split()
        if len(parts) == 2:
            command, name = parts
            if command == "greet":
                results.append(f"Hello, {name}!")
            elif command == "farewell":
                results.append(f"Goodbye, {name}!")

    return "\n".join(results)

editor = CodeEditor(
    executor=greeting_dsl,
    code="greet Alice\nfarewell Bob",
    language="dsl"
)

OpenAI Chat

from ontonaut import ChatBot, OpenAIHandler
import os

chatbot = ChatBot(
    handler=OpenAIHandler(
        api_key=os.getenv("OPENAI_API_KEY"),
        model="gpt-4",
        system_prompt="You are a helpful assistant.",
        temperature=0.7
    ),
    theme="dark"
)

Custom Streaming Handler

def my_handler(message: str):
    """Custom streaming handler."""
    import time

    # Generate code example
    if "code" in message.lower():
        yield "Here's a Python example:\n\n"
        yield "```python\n"
        yield "def greet(name):\n"
        yield "    return f'Hello {name}!'\n"
        yield "```"
    else:
        words = f"You said: {message}".split()
        for word in words:
            yield word + " "
            time.sleep(0.05)

chatbot = ChatBot(handler=my_handler)

๐ŸŽจ Built-in Components

Executors

  • PythonExecutor - Execute Python code
  • JSONExecutor - Format and validate JSON
  • CalculatorExecutor - Evaluate math expressions
  • RegexExecutor - Test regular expressions

Handlers

  • EchoHandler - Echo back messages (testing)
  • OpenAIHandler - Stream from OpenAI GPT models
  • AnthropicHandler - Stream from Anthropic Claude
  • MCPHandler - Model Context Protocol integration
  • CustomHandler - Wrap any function

โŒจ๏ธ Keyboard Shortcuts

  • Cmd/Ctrl + Enter - Execute/Send
  • Tab - Insert 4 spaces

๐Ÿ—๏ธ Development

Setup

git clone https://github.com/yourusername/ontonaut.git
cd ontonaut
make setup

Commands

make test     # Run tests with coverage
make lint     # Run linters (black, ruff, mypy)
make format   # Format code
make build    # Build package
make clean    # Clean artifacts

Project Structure

ontonaut/
โ”œโ”€โ”€ src/ontonaut/          # Python package
โ”‚   โ”œโ”€โ”€ editor.py          # CodeEditor widget
โ”‚   โ”œโ”€โ”€ chatbot.py         # ChatBot widget
โ”‚   โ”œโ”€โ”€ executors.py       # Code execution backends
โ”‚   โ”œโ”€โ”€ handlers.py        # Chat handlers
โ”‚   โ””โ”€โ”€ static/            # Frontend assets
โ”œโ”€โ”€ tests/                 # Test suite
โ”œโ”€โ”€ examples/              # Example notebooks
โ”œโ”€โ”€ book/
โ”‚   โ”œโ”€โ”€ markdown/          # User documentation
โ”‚   โ””โ”€โ”€ marimo/            # Interactive notebooks
โ”œโ”€โ”€ docs/                  # Architecture documentation
โ””โ”€โ”€ scripts/               # Development scripts

๐Ÿงช Testing

make test

Coverage: 85%+ across all components

๐Ÿ“ Use Cases

  • AI Chat Interfaces - Streaming AI assistants in notebooks
  • DSL Prototyping - Test domain-specific language ideas
  • Custom Interpreters - Specialized code execution
  • Educational Tools - Interactive coding tutorials
  • Data Transformation - Custom data processing
  • Template Languages - Specialized templating
  • Company Integrations - Wrap internal AI APIs

๐ŸŽฏ Roadmap

CodeEditor

  • Syntax highlighting
  • Code completion
  • Multi-file support
  • Debugger integration

ChatBot

  • Syntax highlighting for code blocks
  • Copy-to-clipboard
  • Tab persistence
  • Export conversations
  • Async handler support

๐Ÿค Contributing

Contributions welcome! See docs/README.md for architecture and development guidelines.

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Run tests (make test) and linting (make lint)
  4. Commit changes
  5. Push to branch
  6. Open Pull Request

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Built with Anywidget
  • Designed for marimo
  • Inspired by the need for flexible, customizable widgets
  • Thanks to the open source community

๐Ÿ“š Learn More

๐Ÿ”— Links


Made with โค๏ธ for the marimo and Python communities

Start building your custom widgets today! ๐Ÿš€

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

ontonaut-0.1.0.tar.gz (81.2 kB view details)

Uploaded Source

Built Distribution

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

ontonaut-0.1.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file ontonaut-0.1.0.tar.gz.

File metadata

  • Download URL: ontonaut-0.1.0.tar.gz
  • Upload date:
  • Size: 81.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ontonaut-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fb9fbf08a5050d3b4b48050abf033822ec87c1123f78fa9f92c95dc8b4ffa9f3
MD5 515f70bec6b42b57eb0042d58ca7cd3e
BLAKE2b-256 f8ff8fa4fd3e916523a706762bb40a3012464c1e060f23a44963cba475ef525f

See more details on using hashes here.

File details

Details for the file ontonaut-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ontonaut-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ontonaut-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93c78f2987693372bdfa75a78ff16547c680032cebb0fae17a28e49519f69bd1
MD5 b0276f0fc7ab5fe8ae5792a9b8c6d3cf
BLAKE2b-256 1bf73ae0969090e686a0ba077fb0b3e2ade0f1cca637a5a9e0fb5ef8669b78f4

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