MDL.AI
Generate notebook code blocks with LLMs that you can run interactively with any programming language. The source code is pure markdown and can render anywhere.
Quick Start
- Open or create a
.md
document and create a new cell
- Select a language down the bottom right
- Click the run button to generate the output which is saved to markdown
Important Note
When you right-click on a file and select Reopen Editor With...
you can configure default editor
to be the standard Text Editor
if you choose, and then reopen wth mdl
only when you need it.
AI Code Generation
OpenAI
- Set up an OpenAI key here and change the setting:
mdl: openai key
- Default model is
gpt-3.5-turbo
, change the setting with mdl: openai model
e.g. gpt-4
- Select
openai
as your language in the bottom right and ask a question
- Run the code blocks it generates for you
Groq
- Set up a Groq key here and change the setting:
mdl: Groq key
- Select
llama3-8b
as your language and ask it a question
- Run the code blocks it generates for you
How it works
Straight nodejs stateless implementation for notebooks with no external binaries or npm runtime dependencies, works with compiled languages. Rather than using complicated kernels, it simply spawns a process that runs your local toolchain for the language you're using, and returns the output.
You don't have to go back and run old cells if you change them, every execution runs the whole program and sends output to the correct cell.
Keybindings
You can change keybindings in File > Preferences > Keybindings > search for "mdl". Or you can run them via command palette typing in "mdl"
Search notes
Set up a folder with .md
documents in mdl: base path
and press alt+f
to open a open search. This allows you to quickly search through your notes and execute code blocks. If you've ever used vimwiki this might bring back memories, but it's not reliant on a specific structure so you can set up your files for whatever static site generator you like.
Open generated code
Press alt+o
to open up the source code being used to generate outputs, which will allow you to check your code with a language server if it's not supported in the cells yet.
Language Support
It's very simple to add your own language, look inside src/languages/rust.ts for an example, then add your language to the switch statement in src/kernel.ts
. PRs welcomed!
This README.md was created with MDL.AI, these are some special features for different languages:
Python
Python has full LSP support and features you expect from Jupyter like printing out the last expression or variable in a cell:
x = [5, 6, 7, 8]
x.reverse()
x
[8, 7, 6, 5]
Mojo
Mojo is a new Systems programming language for AI developers with Python syntax and interop.
It works with top level code and has some extra features like printing the last line.
Anything you create in an MDL.AI notebook with Python will be available from Mojo via the py
module:
var res = String("Adding a String from Python to a Mojo variable: ") + py.x
res
Adding a String from Python to a Mojo variable: [8, 7, 6, 5]
LSP features don't work yet
Rust
Can run top level code, and runs dbg!
on the last line:
let mut x = vec![];
for i in 5..=8 {
x.push(i);
}
x.reverse();
x
[8, 7, 6, 5]
Go
You can write top level code in Go:
import "fmt"
import "os"
import "log"
// Create a slice of integers
numbers := []int{5, 6, 7, 8}
// Reverse the slice
for i, j := 0, len(numbers)-1; i < j; i, j = i+1, j-1 {
numbers[i], numbers[j] = numbers[j], numbers[i]
}
// Print the reversed slice
fmt.Println("Reversed slice:", numbers)
Reversed slice: [8 7 6 5]
Javascript / TypeScript
JavaScript and TypeScript both work with LSP support, TypeScript uses esbuild for much faster responses. It will ask you to run:
npm install -g esbuild-runner
let numbers: number[] = [5, 6, 7, 8];
numbers = numbers.reverse();
console.log(numbers)
[ 8, 7, 6, 5 ]
Shell
You can use different shell languages to run scripts on the host system.
Experimental: Saves ENV changes as you run cells
#!/bin/bash
declare -a my_vec=(5 6 7 8)
reversed=($(printf '%s\n' "${my_vec[@]}" | tac))
echo "[ "${reversed[@]} "]"
[ 8 7 6 5 ]