Customizable code editor widget for marimo with pluggable execution backends
Project description
Ontonaut ๐
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:
- Quick Start - Get up and running in 5 minutes
- CodeEditor Guide - Complete CodeEditor documentation
- ChatBot Guide - Complete ChatBot documentation
- Executors Reference - Built-in executors
- Handlers Reference - Built-in chat handlers
- Custom Executors - Build your own
- Custom Handlers - Build your own
๐ Interactive Notebooks
Runnable marimo notebooks with examples:
- Getting Started - Basic usage
- ChatBot Guide - Complete chat examples
- OpenAI Integration - AI integration
Run them:
marimo edit book/marimo/01-getting-started.py
๐๏ธ Architecture Docs
For developers and AI assistants:
- Architecture Overview - System design
- Widget System - anywidget patterns
- Development Guide - Contributing
๐ก 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/SendTab- 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.
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Run tests (
make test) and linting (make lint) - Commit changes
- Push to branch
- 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
- User Documentation - Complete guides
- Interactive Notebooks - Runnable examples
- Architecture Docs - For developers
- Marimo Documentation
- Anywidget Documentation
๐ Links
- Homepage: https://github.com/yourusername/ontonaut
- Issues: https://github.com/yourusername/ontonaut/issues
- PyPI: https://pypi.org/project/ontonaut/
Made with โค๏ธ for the marimo and Python communities
Start building your custom widgets today! ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb9fbf08a5050d3b4b48050abf033822ec87c1123f78fa9f92c95dc8b4ffa9f3
|
|
| MD5 |
515f70bec6b42b57eb0042d58ca7cd3e
|
|
| BLAKE2b-256 |
f8ff8fa4fd3e916523a706762bb40a3012464c1e060f23a44963cba475ef525f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93c78f2987693372bdfa75a78ff16547c680032cebb0fae17a28e49519f69bd1
|
|
| MD5 |
b0276f0fc7ab5fe8ae5792a9b8c6d3cf
|
|
| BLAKE2b-256 |
1bf73ae0969090e686a0ba077fb0b3e2ade0f1cca637a5a9e0fb5ef8669b78f4
|